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

pmoravec report at bugs.python.org
Wed Sep 5 05:53:19 EDT 2018


pmoravec <pmoravec at redhat.com> added the comment:

> 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.

Thanks for clarification. Could you please confirm what code change in that script is safe, then?

1) looping "while p.poll() == None   pass" to really ensure some status is returned.

2) calling p.wait() before p.poll()

>From a blackbox perspective, I would expect either to provide similar fixing mechanism of my script. But as we call this code snippet concurrently, for random commands that randomly terminates with random outcome / status, can't either fix attempt cause e.g. a deadlock?

Thanks in advance for help / advice.

(just for context if it matters: the snippet is from https://github.com/sosreport/sos/blob/master/sos/utilities.py#L158 where the sos_get_command_output method is called concurrently by more threads)

----------
nosy: +pmoravec

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


More information about the Python-bugs-list mailing list