Author roudkerk
Recipients jjcogliati, roudkerk
Date 2008-04-03.17:38:59
SpamBayes Score 0.069194
Marked as misclassified No
Message-id <1207244343.46.0.112571954585.issue2475@psf.upfronthosting.co.za>
In-reply-to
Content
The problem is that os.wait() does not play nicely with subprocess.py.
Popen.poll() and Popen.wait() use os.waitpid(pid, ...)  which will
raise OSError if pid has already been reported by os.wait().
Popen.poll() swallows OSError and by default returns None.

You can (sort of) fix your program by using
"p.popen(_deadstate='dead')" in place of "p.popen()".  This will make
poll() return 'dead' instead of None if OSError gets caught, but this
is undocumented.

Maybe a subprocess.wait() function could be added which would return a
tuple

    (pid, exitcode, popen_object)

where popen_object is None if the process is "foreign" (i.e. it was
not created by the subprocess module).

It would not be hard to implement this on unix if you don't care about
thread safety.  (On unix Popen.wait() is not thread-safe either, so
maybe thread safety does not matter.)

To implement something similar on windows you would probably need to
use WaitForMultipleObjects() to check whether any process handles are
signalled, but that would involve patching _subprocess.c or using
ctypes or pywin32.
History
Date User Action Args
2008-04-03 17:39:03roudkerksetspambayes_score: 0.069194 -> 0.069194
recipients: + roudkerk, jjcogliati
2008-04-03 17:39:03roudkerksetspambayes_score: 0.069194 -> 0.069194
messageid: <1207244343.46.0.112571954585.issue2475@psf.upfronthosting.co.za>
2008-04-03 17:39:02roudkerklinkissue2475 messages
2008-04-03 17:39:00roudkerkcreate