Continuously running scripts question

Discussion in 'Python' started by Guest, Jun 25, 2010.

  1. Guest

    Guest Guest

    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?

    Thanks.

    Jay
    Guest, Jun 25, 2010
    #1
    1. Advertising

  2. Guest

    Tim Harig Guest

    On 2010-06-25, <> <> wrote:
    [order modified]
    > 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


    I do both. I use cron for large time intervals so that the script is not
    constantly memory resident and I run python continuously, either sleeping
    or pausing for a signal, when the time interval is small enough that the
    init overhead becomes significant.

    > 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?


    You can do the same thing by implementing a supervisor process that
    monitors your worker process so that the supervisor kills and restarts the
    worker process if it doesn't appear to be functioning properly or crashes.

    > 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.


    It sounds to me, since your script is acting on an event, that it
    would benefit from using something like inotify, or whatever your
    system equivilant would be (FSEvents for Mac? FAM framework for general
    POSIX. There are python modules available.), so that your script can
    react when (and only when) it notices changes to the folder in question.
    Tim Harig, Jun 25, 2010
    #2
    1. Advertising

  3. Guest

    Tim Harig Guest

    followup links (Re: Continuously running scripts question)

    On 2010-06-25, Tim Harig <> wrote:
    > It sounds to me, since your script is acting on an event, that it
    > would benefit from using something like inotify, or whatever your
    > system equivilant would be (FSEvents for Mac? FAM framework for general
    > POSIX. There are python modules available.), so that your script can
    > react when (and only when) it notices changes to the folder in question.


    pynotify (Linux inotify):
    http://trac.dbzteam.org/pyinotify

    FSEvents wrapper:
    http://pypi.python.org/pypi/pyobjc-framework-FSEvents/2.2b2

    FAM:
    C libraries and daemon:
    http://savannah.nongnu.org/projects/fam/
    Python wrapper:
    http://sourceforge.net/projects/python-fam/

    Similar functionality is available for other platforms; but, you will need
    to look at the documentation for those platforms for information on how to
    access it.
    Tim Harig, Jun 25, 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,269
    Karl Seguin
    Mar 13, 2005
  2. al schmid
    Replies:
    2
    Views:
    623
    al schmid
    Apr 10, 2005
  3. Unforgiven
    Replies:
    5
    Views:
    495
    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:
    327
    Roland Dick
    Apr 30, 2007
  5. Ian Kelly
    Replies:
    2
    Views:
    296
    Peter H. Coffin
    Jun 27, 2010
Loading...

Share This Page