DebugClients/Python/ThreadExtension.py

branch
maintenance
changeset 6206
a02b03b7bfec
parent 6050
25a4ddb25ca4
parent 6196
7135a692e43e
child 6646
51eefa621de4
--- a/DebugClients/Python/ThreadExtension.py	Sun Mar 04 14:55:23 2018 +0100
+++ b/DebugClients/Python/ThreadExtension.py	Mon Apr 02 12:04:18 2018 +0200
@@ -321,9 +321,13 @@
                     sys.settrace(None)
             
             class ThreadWrapper(module.Thread):
-                """ Wrapper class for threading.Thread. """
-                
+                """
+                Wrapper class for threading.Thread.
+                """
                 def __init__(self, *args, **kwargs):
+                    """
+                    Constructor
+                    """
                     # Overwrite the provided run method with our own, to
                     # intercept the thread creation by threading.Thread
                     self.run = lambda s=self, run=self.run: _bootstrap(s, run)
@@ -331,6 +335,28 @@
                     super(ThreadWrapper, self).__init__(*args, **kwargs)
             
             module.Thread = ThreadWrapper
+            
+            # Special handling of threading.(_)Timer
+            if sys.version_info[0] == 2:
+                timer = module._Timer
+            else:
+                timer = module.Timer
+                
+            class TimerWrapper(timer, ThreadWrapper):
+                """
+                Wrapper class for threading.(_)Timer.
+                """
+                def __init__(self, interval, function, *args, **kwargs):
+                    """
+                    Constructor
+                    """
+                    super(TimerWrapper, self).__init__(
+                        interval, function, *args, **kwargs)
+            
+            if sys.version_info[0] == 2:
+                module._Timer = TimerWrapper
+            else:
+                module.Timer = TimerWrapper
         
         # Add hook for *.QThread
         elif (fullname in ['PyQt4.QtCore', 'PyQt5.QtCore',
@@ -375,9 +401,13 @@
                     sys.settrace(None)
         
             class QThreadWrapper(module.QThread):
-                """ Wrapper class for *.QThread. """
-                
+                """
+                Wrapper class for *.QThread.
+                """
                 def __init__(self, *args, **kwargs):
+                    """
+                    Constructor
+                    """
                     # Overwrite the provided run method with our own, to
                     # intercept the thread creation by Qt
                     self.run = lambda s=self, run=self.run: (

eric ide

mercurial