another fix

This commit is contained in:
Miroslav Stampar 2010-04-06 15:28:34 +00:00
parent a6a2e993cc
commit 3fe9f9cac9

View File

@ -8,7 +8,6 @@ def timeout(func, args=(), kwargs={}, duration=1, default=None):
class InterruptableThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.exceeded = False
self.result = None
def run(self):
@ -21,8 +20,7 @@ def timeout(func, args=(), kwargs={}, duration=1, default=None):
thread = InterruptableThread()
thread.start()
thread.join(duration)
self.exceeded = thread.isAlive()
if self.exceeded:
if thread.isAlive():
return default
else:
return thread.result