Re: Create a process with a "time to live"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fredrik Lundh

    Re: Create a process with a "time to live"

    Carl J. Van Arsdall wrote:
    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.
    simple approach: use subprocess.Pope n to fork off the external command,
    then sleep for a short while, check if it's done, sleep a little longer
    if it hasn't, etc. when you've waited long enough, use os.kill to kill
    the process.

    (if you want to terminate a function in your own program, you can use
    the alarm signal. see e.g. http://code.activestate.com/recipes/307871/ )

    </F>

Working...