Subprocess timeout

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • George Sakkis

    #1

    Subprocess timeout

    I'm trying to use a threaded timeout decorator (http://
    aspn.activestat e.com/ASPN/Cookbook/Python/Recipe/483752) to spawn a
    subprocess with a timeout. On a linux box runnning python 2.5 I get
    "OSError: [Errno 10] No child processes" on wait(); running the same
    program on a different box (again linux) with python 2.4 doesn't throw
    an exception. Here's a sample snippet:

    import os
    from subprocess import Popen,PIPE

    @timelimit(3)
    def f(cmd):
    return Popen(cmd, stdout=PIPE)


    p = f('ls')
    print os.getpid(), p.pid
    # the next line raises OSError on 2.5 but not on 2.4
    print os.waitpid(p.pi d, 0)

    What gives ?

    George

Working...