code: def _thread_excepthook():
      
      init_old = thread.Thread.__init__
      def init(self, *args, **kwargs):
          init_old(self, *args, **kwargs)
          run_old = self.run
          def run_with_except_hook(*args, **kw):
              try:
                  run_old(*args, **kw)
              except (KeyboardInterrupt, SystemExit):
  
                  raise
              except:
                  sys.excepthook(*sys.exc_info())
          self.run = run_with_except_hook
      thread.Thread.__init__ = init
docs: Make threads use sys.excepthook from parent process
      http://bugs.python.org/issue1230540