File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ def _init_signals():
1212 """Assure we shutdown our threads correctly when being interrupted"""
1313 import signal
1414 import thread
15+ import sys
1516
1617 prev_handler = signal .getsignal (signal .SIGINT )
1718 def thread_interrupt_handler (signum , frame ):
@@ -21,7 +22,12 @@ def thread_interrupt_handler(signum, frame):
2122 raise KeyboardInterrupt ()
2223 # END call previous handler
2324 # END signal handler
24- signal .signal (signal .SIGINT , thread_interrupt_handler )
25+ try :
26+ signal .signal (signal .SIGINT , thread_interrupt_handler )
27+ except ValueError :
28+ # happens if we don't try it from the main thread
29+ print >> sys .stderr , "Failed to setup thread-interrupt handler. This is usually not critical"
30+ # END exception handling
2531
2632
2733#} END init
You can’t perform that action at this time.
0 commit comments