On Fri, Jun 25, 2010 at 9:49 AM, <jyoun...@kc.rr.com> 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 -- http://mail.python.org/mailman/listinfo/python-list