Grant Edwards wrote:
<snip>On 2009-08-13, Dave Angel <da...@ieee.org> wrote:
Grant Edwards wrote:
<snip>
    interval = 5.0  # interval in seconds
    next = time.time()

    while True:
        now = time.time()
if now < next: time.sleep(now-next)
        print "call_the_function()"
        next += interval

That will be accurate over the long term with minimal jitter.
<snip>
2) If (occasionally) the function takes longer than the
   specified interval time, my approach does catch-up calls so
   the average remains the same.

I'm still confused -- doesn't mine do that as well?

Yep. I missed it again. Clearly it does the catchup the next time around the while loop.

DaveA
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to