[issue19326] asyncio: child process exit isn't detected if its stdin/stdout/stderr FDs have been inherited by a child process

Guido van Rossum report at bugs.python.org
Mon Oct 21 18:49:41 CEST 2013


Guido van Rossum added the comment:

This is by design. Let me try to defend the design.

As long as one of the pipes is still open the parent might be interested in it. The Protocol object does get notified of the process's exit, via process_exited(), and if at that point it wants to be done, it can close the pipes itself. (To do that, call transport.get_pipe_transport(FD).close().) Once that's done the subprocess protocol's connection_lost() method will be called.

I suppose an alternative approach might be to assume that when the subprocess exist the parent should close the pipes and be done, but there's a race condition there: there may still be data in one of the pipes (stdout or stderr) that should be processed before calling connection_lost(), similar to how we delay the socket connection_lost() call until we have processed all data read from it.

So I don't think that alternative is viable.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19326>
_______________________________________


More information about the Python-bugs-list mailing list