repost: http web page fetch question

Emile van Sebille emile at fenx.com
Fri Apr 24 14:21:28 EDT 2009


grocery_stocker wrote:
> Given the following...
> 
> [cdalten at localhost oakland]$ more basic.py
<snip>
> 
> How do I modify it so that it runs every hour on the hour.

I'd probably use cron, but here's one way.

Emile
-----

import sched
import time

scheduler = sched.scheduler(time.time, time.sleep)

def print_event(count,rescheduler):
         print 'EVENT:', time.time(), count
         rescheduler.enter(2,1,print_event,(count+1,rescheduler))

print 'START:', time.time()
scheduler.enter(2, 1, print_event, (1,scheduler))

scheduler.run()



More information about the Python-list mailing list