Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Continuously running scripts question

Reply
Thread Tools

Re: Continuously running scripts question

 
 
Ian Kelly
Guest
Posts: n/a
 
      06-25-2010
On Fri, Jun 25, 2010 at 9:49 AM, <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      06-27-2010
In message <(E-Mail Removed)>, 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?
 
Reply With Quote
 
 
 
 
Peter H. Coffin
Guest
Posts: n/a
 
      06-27-2010
On Sun, 27 Jun 2010 16:21:25 +1200, Lawrence D'Oliveiro wrote:
> In message <(E-Mail Removed)>, 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU running continuously at 90% on one core Lorne Windows 64bit 6 07-08-2010 03:04 PM
Continuously running scripts question Python 2 06-25-2010 04:41 PM
Stupid question: Making scripts python-scripts Jan Danielsson Python 8 07-22-2005 12:20 AM
Re: Stupid question: Making scripts python-scripts Jp Calderone Python 0 07-21-2005 02:38 PM
how to display time continuously in asp.net--plz help me karanam ravi kiran via DotNetMonster.com ASP .Net 1 03-13-2005 02:24 PM



Advertisments