Schedule Task

Robert Rawlins - Think Blue robert.rawlins at thinkbluemedia.co.uk
Sat Apr 21 03:45:03 EDT 2007


Hello Guys,

 

I've got a method in my app that I want to run every 20 minutes that the
application it running, what's the best way of achieving this? At the moment
I'm using this kind of method.

 

import sched

import time, sys

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

 

scheduler.enter(1.0, 0, sys.stdout.write, ("one\n",))

scheduler.run()

 

Now when the function runs after 20 minutes I just have it schedule itself
to run again in 20 minutes time, which seems to work for me quite nicely, it
just seems a little 'hacky' to keep the task reoccurring like that.

 

Is there any other method? I've spent some time on Google but couldn't
really find anything. Not sure if it makes any difference but I'm running
Linux.

 

Thanks,

 

Rob

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070421/210e2603/attachment.html>


More information about the Python-list mailing list