os.wait() losing child?
Xin.Zheng at jpl.nasa.gov
Wed Jul 11 20:48:40 CEST 2007
Matthew Woodcraft wrote:
> greg <greg at cosc.canterbury.ac.nz> wrote:
>> I've figured out what's going on. The Popen class has a
>> __del__ method which does a non-blocking wait of its own.
>> So you need to keep the Popen instance for each subprocess
>> alive until your wait call has cleaned it up.
> I don't think this will be enough for the poster, who has Python 2.4:
> in that version, opening a new Popen object would trigger the wait on
> all 'outstanding' Popen-managed subprocesses.
> It seems to me that subprocess.py assumes that it will do all wait()ing
> on its children itself; I'm not sure if it's safe to rely on the
> details of how this is currently arranged.
> Perhaps a better way would be for subprocess.py to provide its own
> variant of os.wait() for people who want 'wait-for-any-child' (though
> it would be hard to support programs which also had children not
> managed by subprocess.py).
Thanks, that's exactly what I need, my program really needs the
os.wait() to be reliable. Perhaps I could pass a flag to Popen to tell
it to never os.wait() on the new pid (but it's ok to os.wait() on other
Popen instances upon _cleanup()).
More information about the Python-list