[issue23570] Change "with subprocess.Popen():" (context manager) to ignore broken pipe error

Martin Panter report at bugs.python.org
Sun Mar 8 03:11:27 CET 2015


Martin Panter added the comment:

After understanding the Windows test failure in Issue 21619, I am starting to believe that code relying on a BrokenPipeError or EPIPE is flawed. It is an inherent unavoidable race condition with the receiving end of the pipe, as long as another thread or process is involved, which is always the case for the subprocess module. Another way of looking at it is that there is no guarantee that your data will have been (or will be) received, even if stdin.close() succeeds and does not raise EPIPE or similar. This is because piped data is buffered by the OS.

So the proposed change wouldn’t be a significant disadvantage, except for code that is already flawed. It is analogous to the argument used for ignoring EINTR, because depending on it for handling signals is inherently racy.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23570>
_______________________________________


More information about the Python-bugs-list mailing list