File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 22
22
from .rate_control import rate
23
23
24
24
25
+ # Redefine `Thread.run` to not show a traceback for Spyder when stopping
26
+ # the server by raising a KeyboardInterrupt or SystemExit.
27
+ if _in_spyder :
28
+ def install_thread_stopped_message ():
29
+ """
30
+ Workaround to prevent showing a traceback when VPython server stops.
31
+
32
+ See:
33
+ https://bugs.python.org/issue1230540
34
+ """
35
+ run_old = threading .Thread .run
36
+
37
+ def run (* args , ** kwargs ):
38
+ try :
39
+ run_old (* args , ** kwargs )
40
+ except (KeyboardInterrupt , SystemExit ):
41
+ print ("VPython server stopped." )
42
+ except :
43
+ raise
44
+ threading .Thread .run = run
45
+
46
+ install_thread_stopped_message ()
47
+
48
+
49
+
25
50
# Check for Ctrl+C. SIGINT will also be sent by our code if WServer is closed.
26
51
def signal_handler (signal , frame ):
27
52
stop_server ()
You can’t perform that action at this time.
0 commit comments