DebugClients/Python/ThreadExtension.py

changeset 6196
7135a692e43e
parent 6195
186cbd6b15b1
child 6206
a02b03b7bfec
child 6645
ad476851d7e0
equal deleted inserted replaced
6195:186cbd6b15b1 6196:7135a692e43e
319 newThread.user_exception(excinfo, True) 319 newThread.user_exception(excinfo, True)
320 finally: 320 finally:
321 sys.settrace(None) 321 sys.settrace(None)
322 322
323 class ThreadWrapper(module.Thread): 323 class ThreadWrapper(module.Thread):
324 """ Wrapper class for threading.Thread. """ 324 """
325 325 Wrapper class for threading.Thread.
326 """
326 def __init__(self, *args, **kwargs): 327 def __init__(self, *args, **kwargs):
327 """ Constructor. """ 328 """
329 Constructor
330 """
328 # Overwrite the provided run method with our own, to 331 # Overwrite the provided run method with our own, to
329 # intercept the thread creation by threading.Thread 332 # intercept the thread creation by threading.Thread
330 self.run = lambda s=self, run=self.run: _bootstrap(s, run) 333 self.run = lambda s=self, run=self.run: _bootstrap(s, run)
331 334
332 super(ThreadWrapper, self).__init__(*args, **kwargs) 335 super(ThreadWrapper, self).__init__(*args, **kwargs)
338 timer = module._Timer 341 timer = module._Timer
339 else: 342 else:
340 timer = module.Timer 343 timer = module.Timer
341 344
342 class TimerWrapper(timer, ThreadWrapper): 345 class TimerWrapper(timer, ThreadWrapper):
343 """ Wrapper class for threading.(_)Timer. """ 346 """
344 347 Wrapper class for threading.(_)Timer.
348 """
345 def __init__(self, interval, function, *args, **kwargs): 349 def __init__(self, interval, function, *args, **kwargs):
346 """ Constructor. """ 350 """
351 Constructor
352 """
347 super(TimerWrapper, self).__init__( 353 super(TimerWrapper, self).__init__(
348 interval, function, *args, **kwargs) 354 interval, function, *args, **kwargs)
349 355
350 if sys.version_info[0] == 2: 356 if sys.version_info[0] == 2:
351 module._Timer = TimerWrapper 357 module._Timer = TimerWrapper
393 newThread.user_exception(excinfo, True) 399 newThread.user_exception(excinfo, True)
394 finally: 400 finally:
395 sys.settrace(None) 401 sys.settrace(None)
396 402
397 class QThreadWrapper(module.QThread): 403 class QThreadWrapper(module.QThread):
398 """ Wrapper class for *.QThread. """ 404 """
399 405 Wrapper class for *.QThread.
406 """
400 def __init__(self, *args, **kwargs): 407 def __init__(self, *args, **kwargs):
408 """
409 Constructor
410 """
401 # Overwrite the provided run method with our own, to 411 # Overwrite the provided run method with our own, to
402 # intercept the thread creation by Qt 412 # intercept the thread creation by Qt
403 self.run = lambda s=self, run=self.run: ( 413 self.run = lambda s=self, run=self.run: (
404 _bootstrapQThread(s, run)) 414 _bootstrapQThread(s, run))
405 415

eric ide

mercurial