On Wed, 12 Aug 2009 14:09:29 -0700, David wrote:
>
> Hi all, I'm trying to launch a function at regular time intervals but
> cannot find the way to do it.
>

For what it's worth, here's how I do it:

---------------8<---------------

#!/usr/bin/env python
from time import sleep

interval = 25 #seconds

while not sleep(interval):
    f(spam, eggs, knight)

---------------8<---------------

You might want to put the sleep inside an *obviously* infinite loop. Note 
that this works best (most accurately) for longer periods. If you need to
account for the time spent in the actual f() calls, plug in a time.time() 
call where appropriate.

-- 
| <")-, | ''The good-enough is the enemy of the excellent.'' - John Miles 
| (_==/ |-----------,-----------------------------------------------------
|  ='-  | Bartosz Wroblewski | bawr from holyhandgrenade.info or int8.org 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to