threading module timer object
.d.hos
dhostetler at sopris.net
Mon Feb 3 18:09:02 EST 2003
hello all,
I have a multithreading app, and I want to watch each thread with a
timeout function.
currently, I using the the threading modules timer object, and
try:/except: statements, to raise a user defined exception. The user
defined exception is raised after the said timespan passes, but
processing that occurs after catching the exception never happens.
I think i'm fairly close to getting this working, but can't figure out
what i'm doing wrong here. any input?
class workerThread(threading.Thread):
def __init__(self, queue, threadNo=None):
self.__queue = queue
self.__TimeOut = "Thread timed out"
threading.Thread.__init__(self)
def flagIt(self):
raise self.__TimeOut
def run(self):
try:
t = threading.Timer(5.0, self.flagIt)
t.start()
#do something here
self.__queue.put("mission complete")
except self.__TimeOut:
self.__queue.put("timeout error")
Regards,
.d.hos
More information about the Python-list
mailing list