Create a process with a "time to live"

John Krukoff jkrukoff at ltgc.com
Fri Aug 15 20:00:03 CEST 2008


On Fri, 2008-08-15 at 10:00 -0700, Carl J. Van Arsdall wrote:
> Hey python[],
> 
> I want to create a process that would "expire" if it didn't complete in 
> a set amount of time.  I don't seem to see any timeout values to pass 
> os.system - does anyone know of a good way to do this? 
> 
> So far all I can think of is some kind of watchdog thread - but that 
> seems like overkill to do such a simple thing.
> 
> 
> -Carl

Well, if you're on unix, the signal module is probably the easiest
method:

Python 2.5.2 (r252:60911, Jul 31 2008, 15:38:58) 
[GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import signal
>>> signal.alarm( 1 )
0
>>> Alarm clock

(Interpreter exits)

-- 
John Krukoff <jkrukoff at ltgc.com>
Land Title Guarantee Company




More information about the Python-list mailing list