[issue35182] Popen.communicate() breaks when child closes its side of pipe but not exits

Josh Rosenberg report at bugs.python.org
Wed Nov 7 15:20:51 EST 2018


Josh Rosenberg <shadowranger+python at gmail.com> added the comment:

Hmm... Correction to my previous post. communicate itself has a test for:

"if self._communication_started and input:"

that raises an error if it passes, so the second call to communicate can only be passed None/empty input. And _communicate only explicitly closes self.stdin when input is falsy and _communication_started is False, so the required behavior right now is:

1. First call *may* pass input
2. Second call must not pass (non-empty) input under any circumstance

So I think we're actually okay on the code for stdin, but it would be a good idea to document that input *must* be None on all but the first call, and that the input passed to the first call is cached such that as long as at least one call to communicate completes without a TimeoutError (and the stdin isn't explicitly closed), it will all be sent.

Sorry for the noise; I should have rechecked communicate itself, not just _communicate.

----------

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


More information about the Python-bugs-list mailing list