This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Griffon26
Recipients Griffon26
Date 2017-02-07.11:57:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1486468634.65.0.790221754194.issue29472@psf.upfronthosting.co.za>
In-reply-to
Content
This only happens when:
- timeout is small enough
- at least one stream is redirected to a PIPE

When I know for certain that a subprocess has already terminated and I call communicate to retrieve its results with a timeout of 0 (or other small enough value), communicate will always return TimeoutExpired.

The cause is that the check on timeout is done before the ready file descriptors are checked: https://hg.python.org/cpython/file/tip/Lib/subprocess.py#l1484. With a small enough timeout, communicate will never check the file descriptors for EOF.

From a user perspective I would expect to be able to use communicate(timeout=0) to get the output for a process that I know has already terminated or to poll without blocking.

Is this the intended behaviour of communicate or is it a bug? To me this behaviour is surprising.
History
Date User Action Args
2017-02-07 11:57:14Griffon26setrecipients: + Griffon26
2017-02-07 11:57:14Griffon26setmessageid: <1486468634.65.0.790221754194.issue29472@psf.upfronthosting.co.za>
2017-02-07 11:57:14Griffon26linkissue29472 messages
2017-02-07 11:57:14Griffon26create