timer

Paul Moore p.f.moore at gmail.com
Tue Jun 30 08:54:21 EDT 2009


2009/6/30 superpollo <user at example.net>:
> Paul Moore wrote:
>> For a non-toy example, you'd probably create an Event object, use your
>> timer to set the event, and your while loop would do while
>> event.is_set(), so the problem wouldn't arise.
>
> thank u paul. if u dont mind, would you give me a more detailed piece of
> code that does what i mean?

No problem:

import threading

e = threading.Event()
t = threading.Timer(3.0, e.set)
t.start()

while not e.is_set():
    print "Hello, threading world"

Hope this helps,
Paul



More information about the Python-list mailing list