Re: Continuously running scripts question

Discussion in 'Python' started by Ian Kelly, Jun 25, 2010.

  1. Ian Kelly

    Ian Kelly Guest

    On Fri, Jun 25, 2010 at 9:49 AM, <> wrote:
    > Currently, I have some scripts (in particular, applescript
    > 'stay-open' scripts) that run continuously on a Mac through
    > the day.  They look in a certain folder every 30 seconds and
    > perform the necessary work needed.
    >
    > I was curious if anyone here on the list does anything similar
    > with Python?  If so, do you use launchd, cron, etc in order to
    > start up your Python script at the appropriate time(s)?  Or do
    > you just let your Python code run continuously?  I'm curious of
    > the pros and cons with each of these.  I'm assuming launchd (or
    > something similar) is probably the better option since if a
    > script broke it would start it back up again the next time
    > around.  Launchd also probably doesn't use as much processing
    > power?


    I use cron.

    Pro: You don't have to worry about an unusual exception crashing your
    script and requiring a restart. You fix the exception when you can,
    and in the meantime your script is still being run.

    Con: Most cron implementations have a maximum frequency of once per minute..
    Con: Starting a fresh Python interpreter is expensive, and doing it
    once or twice per minute could add significantly if the system is
    already under a heavy load.

    When I do this, my scripts generally run once every 15 minutes or
    thereabouts, so the cons don't really apply.

    Cheers,
    Ian
    Ian Kelly, Jun 25, 2010
    #1
    1. Advertising

  2. In message <>, Ian Kelly
    wrote:

    > I use cron.
    >
    > Con: Most cron implementations have a maximum frequency of once per
    > minute.


    Another con is: what happens if a run takes longer than the invocation
    frequency?
    Lawrence D'Oliveiro, Jun 27, 2010
    #2
    1. Advertising

  3. On Sun, 27 Jun 2010 16:21:25 +1200, Lawrence D'Oliveiro wrote:
    > In message <>, Ian Kelly
    > wrote:
    >
    >> I use cron.
    >>
    >> Con: Most cron implementations have a maximum frequency of once per
    >> minute.

    >
    > Another con is: what happens if a run takes longer than the invocation
    > frequency?


    Not cron's problem. Whatever mechanism you use to prevent
    fumble-fingered keyboard actuators from running your thing more than
    once simulaneously will suffice for cron as well.

    --
    Don't use this code for realtime control, for weapons systems, or for
    anything else that may put life or limb at hazard. It isn't man-rated,
    it isn't really thing-rated, and we don't claim that it's worth a good
    G*dDamn for anything at all, at all. -- Mike Andrews, on Java compilers
    Peter H. Coffin, Jun 27, 2010
    #3
    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. karanam ravi kiran via DotNetMonster.com

    how to display time continuously in asp.net--plz help me

    karanam ravi kiran via DotNetMonster.com, Mar 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    8,271
    Karl Seguin
    Mar 13, 2005
  2. al schmid
    Replies:
    2
    Views:
    623
    al schmid
    Apr 10, 2005
  3. Unforgiven
    Replies:
    5
    Views:
    496
    Unforgiven
    Oct 16, 2003
  4. =?Utf-8?B?TWVuYWth?=

    Continuously Transaction Number

    =?Utf-8?B?TWVuYWth?=, Apr 30, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    328
    Roland Dick
    Apr 30, 2007
  5. Guest
    Replies:
    2
    Views:
    625
    Tim Harig
    Jun 25, 2010
Loading...

Share This Page