Re: Python scheduler

Discussion in 'Python' started by Terry Reedy, Feb 21, 2013.

  1. Terry Reedy

    Terry Reedy Guest

    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
    Terry Reedy, Feb 21, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Codemonkey
    Replies:
    8
    Views:
    9,495
  2. project2501

    python thread scheduler?

    project2501, Apr 7, 2004, in forum: Python
    Replies:
    2
    Views:
    359
  3. Guest

    Re: python thread scheduler?

    Guest, Apr 7, 2004, in forum: Python
    Replies:
    1
    Views:
    414
    project2501
    Apr 8, 2004
  4. Eric @ Zomething

    Windows XP - cron or scheduler for Python?

    Eric @ Zomething, Jun 20, 2004, in forum: Python
    Replies:
    19
    Views:
    4,597
    Esmail Bonakdarian
    Dec 27, 2004
  5. Tim Golden
    Replies:
    4
    Views:
    551
    Emilio
    Dec 23, 2004
Loading...

Share This Page