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