Repeating Thread Error
Steve Holden
steve at holdenweb.com
Fri Jul 6 20:18:23 EDT 2007
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
>
Here's a little thread-test program I wrote a few years ago. I hope it
will explain how threads and sleeps interact.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: threadtest.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20070706/afa42c47/attachment.ksh>
More information about the Python-list
mailing list