Beremiz.py
changeset 1067 4f460c1dffb5
parent 1061 02f371f3e063
child 1087 16cc3c42e413
--- a/Beremiz.py	Wed Apr 24 23:53:23 2013 +0200
+++ b/Beremiz.py	Thu Apr 25 11:54:07 2013 +0900
@@ -1132,6 +1132,7 @@
 #-------------------------------------------------------------------------------
 #                               Exception Handler
 #-------------------------------------------------------------------------------
+import threading, traceback
 
 Max_Traceback_List_Size = 20
 
@@ -1226,6 +1227,20 @@
     #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args)
     sys.excepthook = handle_exception
 
+    init_old = threading.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
+    threading.Thread.__init__ = init
+
 if __name__ == '__main__':
     # Install a exception handle for bug reports
     AddExceptHook(os.getcwd(),updateinfo_url)