Make StoppableThread.JoinThread have a configurable retry interval (still default 2 seconds). Will attempt to retry stopping thread every this-many seconds
This commit is contained in:
parent
e554cd0252
commit
d6ff5e1932
@ -32,15 +32,16 @@ class JoinThread(threading.Thread):
|
|||||||
JoinThread - The workhouse that stops the StoppableThread
|
JoinThread - The workhouse that stops the StoppableThread
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, otherThread, exception):
|
def __init__(self, otherThread, exception, repeatEvery=2.0):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.otherThread = otherThread
|
self.otherThread = otherThread
|
||||||
self.exception = exception
|
self.exception = exception
|
||||||
|
self.repeatEvery = repeatEvery
|
||||||
self.daemon = True
|
self.daemon = True
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while self.otherThread.isAlive():
|
while self.otherThread.isAlive():
|
||||||
# We loop raising exception incase it's caught hopefully this breaks us far out.
|
# We loop raising exception incase it's caught hopefully this breaks us far out.
|
||||||
ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(self.otherThread.ident), ctypes.py_object(self.exception))
|
ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(self.otherThread.ident), ctypes.py_object(self.exception))
|
||||||
self.otherThread.join(2)
|
self.otherThread.join(self.repeatEvery)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user