Repeating Thread Error

jimxu jimxu at
Sat Jul 7 01:50:52 CEST 2007

hmm.. why use while True? After 5 secs, the function is going to run. so

t = threading.Thread(5.0, func)

should just work. Put it in a infinite loop will start the thread and  
then start a the stopped thread... forever.


On Jul 6, 2007, at 2:40 PM, Jonathan Shan wrote:

> 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