def _init_signals():
 import signal
 import thread
 import sys
 prev_handler = signal.getsignal(signal.SIGINT)
 def thread_interrupt_handler(signum, frame):
  thread.do_terminate_threads()
  if callable(prev_handler):
   prev_handler(signum, frame)
   raise KeyboardInterrupt()
 try:
  signal.signal(signal.SIGINT, thread_interrupt_handler)
 except ValueError:
  print >>sys.stderr, 'Failed to setup thread-interrupt handler. This is usually not critical'

def _init_signals ( ) : import signal import thread import sys prev_handler = signal . getsignal ( signal . SIGINT ) def thread_interrupt_handler ( signum , frame ) : thread . do_terminate_threads ( ) if callable ( prev_handler ) : prev_handler ( signum , frame ) raise KeyboardInterrupt ( ) try : signal . signal ( signal . SIGINT , thread_interrupt_handler ) except ValueError : print >> sys . stderr , 'Failed to setup thread-interrupt handler. This is usually not critical'
assure we shutdown our threads correctly when being interrupted .