Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > re : do something in time interval

Reply
Thread Tools

re : do something in time interval

 
 
Hendrik van Rooyen
Guest
Posts: n/a
 
      10-08-2008
"Petr JakeŇ°" <(E-Mail Removed)> wrote:

>"Leon Zhang" <(E-Mail Removed)> 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.



 
Reply With Quote
 
 
 
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      10-09-2008
In message <(E-Mail Removed)>, Hendrik
van Rooyen wrote:

> 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()


Maybe I'm dense, but ... where do you stop the busy-waiting?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
do something in time interval Petr Jakes Python 4 10-06-2008 07:25 PM
time control doesn't work with interval > 259 Dica ASP .Net 0 11-11-2005 06:01 PM
'point in time' time interval Andrew Poulos Javascript 4 06-15-2005 12:34 AM
Measuring a short interval in time Wes Harrison Java 2 09-14-2004 05:04 PM
Recommendations for Time Lapse Photography - Interval Shooting (correction) No Left Turn Digital Photography 5 09-30-2003 11:16 PM



Advertisments