On 2010-06-25, <jyoun...@kc.rr.com> <jyoun...@kc.rr.com> 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. -- http://mail.python.org/mailman/listinfo/python-list