do something in time interval
Hendrik van Rooyen
mail at microcorp.co.za
Wed Oct 8 00:48:25 EDT 2008
"Petr Jakeš" <petr.jakes at tpc.cz> wrote:
>"Leon Zhang" <safecom at gmail.com> wrote:
>
>>
>> I am not an expert, but why not to use time.sleep(5)?
>> If you are using wxPython, you may also try wx.Timer, in which you could
>> set its interval.
>>
>>
>Thanks for your reply.
>During the 5s period my script has to do some stuff instead of sleeping.
>Thats why it runs in the loop and once in 5s period it has to trigger some
>other stuff(function, method, action) to do.
import time
while True:
end_time = time.time() + 5
while time.time() < end_time:
do_the_in_between_stuff()
do_the_every_five_second_stuff()
HTH - Hendrik
--
Real programmers disdain structured programming. Structured
programming is for compulsive neurotics who were prematurely
toilet-trained. They wear neckties and carefully line up
pencils on otherwise clear desks.
More information about the Python-list
mailing list