re : do something in time interval

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hendrik van Rooyen

    re : do something in time interval

    "Petr Jakeš" <petr.jakes@tpc .czwrote:
    >"Leon Zhang" <safecom@gmail. comwrote:
    >
    >>
    >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_betwe en_stuff()
    do_the_every_fi ve_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.



  • Lawrence D'Oliveiro

    #2
    Re: re : do something in time interval

    In message <mailman.2134.1 223400793.3487. python-list@python.org >, Hendrik
    van Rooyen wrote:
    import time
    while True:
    end_time = time.time() + 5
    while time.time() < end_time:
    do_the_in_betwe en_stuff()
    do_the_every_fi ve_second_stuff ()
    Maybe I'm dense, but ... where do you stop the busy-waiting?

    Comment

    Working...