running a piece of code at specific intervals?

Dave Angel davea at ieee.org
Wed Aug 4 22:07:41 CEST 2010


Chris Hare wrote:
> Don't say cron :
>
> I want to have a section of my code executed at 15 minute intervals.  I am using Threading.timer, but it is causing a problem sinxe I am using sqlite3 and the thread support gives me an error, which aborts part of my code.
>
> So, is there an alternative to threading.timer?
>
>   
Depends on how that "section of code" relates to the rest of your code.  
If it's independent of the rest, then you can use subprocess to launch a 
separate process.  That won't interfere with your main code.  But of 
course if your main code is blocked for 20 minutes, it'll never get to 
the part which should run the subprocess.

If your main code is running wxPython, you can set a timer, and just 
trigger an event like all the others.

But without knowing more about your two pieces of code, the only 
reliable answer is 'cron'.

DaveA




More information about the Python-list mailing list