[issue34566] pipe read sometimes returns EOF but returncode is still None

Martin Panter report at bugs.python.org
Mon Sep 3 20:49:40 EDT 2018


Martin Panter <vadmium+py at gmail.com> added the comment:

The "grep" process may be closing its end of the pipe before it exits. Or if Grep leaves the pipe open when it exits, the OS may close the pipe before it makes the child exit status available. Either way, I suspect "p.stdout.read()" returns an empty string indicating the pipe is closed, but "p.poll()" returns None because the exit status is not yet ready. Even if it is the OS closing the pipe after the child exits, I doubt there is any guarantee about when that happens relative to the child's exit status becoming available.

The "poll" method does not wait for the child to exit. Normally you use the "wait" method in this situation. I suspect this is a bug in the application, not in Python.

----------
nosy: +martin.panter

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34566>
_______________________________________


More information about the Python-bugs-list mailing list