Repeating Thread Error

Jonathan Shan jonshan at winlab.rutgers.edu
Fri Jul 6 17:40:16 EDT 2007


Hello,

I am trying to call a function every 5 seconds. My understanding of
time.sleep() is during the sleep time everything "stops". However, in
my application, there are background processes that must be running
continuously during the five second interval. Thus, threading.Timer
seems like a good function. Here is the relevant code:

# background processes
t = threading.Timer(5.0, function_name, [arguments])
while True:
     # Do background processes run inside while loop?
     t.start()

The above code generates an error:
AssertionError: thread already started

Any hints on how to fix the error? Also, do background processes run
inside while loops?

Thanks in advance,
Jonathan Shan




More information about the Python-list mailing list