timer

Paul Moore p.f.moore at gmail.com
Tue Jun 30 09:19:47 EDT 2009


2009/6/30 superpollo <user at example.net>:
> Paul Moore wrote:
>>
>> 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
>
> do not bother answering... my fault.
>
> i wrote e.set() and not e.set
>
> <hides in shame>
>
> thanks again

No problem - I made the same mistake while I was writing the sample
:-) (I also forgot t.start() the first time. So I'm winning 2-1 on
trivial mistakes :-))

Paul.



More information about the Python-list mailing list