New submission from Maurice van der Pot: 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. ---------- components: Library (Lib) messages: 287230 nosy: Griffon26 priority: normal severity: normal status: open title: subprocess.communicate with timeout 0 and already terminated process generates TimeoutExpired on Linux type: behavior versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29472> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com