Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Python scheduler

Thread Tools

Re: Python scheduler

Terry Reedy
Posts: n/a
On 2/20/2013 11:04 PM, Rita wrote:

> Here is what I am trying to do. (Currently, I am doing this in cron but
> i need much more granularity). I am trying to run program every 20 secs
> and loop forever. I have several of these types of processes, some
> should run every 5 mins, 10 secs, 20 secs, 1 min and so forth. I was
> wondering what is the best way to do this?

One way is to use a heap as a priority queue (see heapq module).
Make a table of (delay, process) pairs.
Load time-to-execute, process pairs in the queue.
Run the main loop:
while True:
get top of queue
sleep time-to-execute - now() seconds
start subprocess
put new time-to-execute, process pair in the queue

This simple version assumes that processes are self-contained and do not
need to communicate with driver process and its loop.

> Also, would Greenlet do something I am asking for?

Don't know.

Terry Jan Reedy

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dotnet scheduler like the Windows "Schedued Tasks" scheduler? Codemonkey ASP .Net 8 06-10-2011 10:53 AM
Windows XP - cron or scheduler for Python? Eric @ Zomething Python 19 12-27-2004 02:55 AM
RE: Windows XP - cron or scheduler for Python? Tim Golden Python 4 12-23-2004 07:15 PM
python thread scheduler? project2501 Python 2 04-09-2004 05:35 PM
Re: python thread scheduler? Python 1 04-08-2004 08:21 AM