DebugClients/Python/ThreadExtension.py

changeset 6195
186cbd6b15b1
parent 6048
82ad8ec9548c
child 6196
7135a692e43e
diff -r 05df94843dd5 -r 186cbd6b15b1 DebugClients/Python/ThreadExtension.py
--- a/DebugClients/Python/ThreadExtension.py	Tue Mar 13 19:48:43 2018 +0100
+++ b/DebugClients/Python/ThreadExtension.py	Wed Mar 21 22:13:31 2018 +0100
@@ -324,6 +324,7 @@
                 """ 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 +332,25 @@
                     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',

eric ide

mercurial