Josh Rosenberg <shadowranger+pyt...@gmail.com> added the comment:

If the goal is just to suppress stdout, that's what passing subprocess.DEVNULL 
is for (doesn't exist in Py2, but opening os.devnull and passing that is a 
slightly higher overhead equivalent).

subprocess.run includes a call to communicate as part of its default behavior, 
and stores its results, so call() isn't quite equivalent to run().returncode 
when PIPE was passed for standard handles, because call only includes an 
implicit call to wait, not communicate, and therefore pipes are not explicitly 
read and can block.

Basically, subprocess.run is deadlock-safe (because it uses communicate, not 
just wait), but if you don't care about the results, and the results might be 
huge, don't pass it PIPE for stdout/stderr (because it will store the complete 
outputs in memory, just like any use of communicate with PIPE).

The docs effectively tell you PIPE is safe; it returns a CompletedProcess 
object, and explicitly tells you that it has attributes that are (completely) 
populated based on whether capture was requested. If it had such attributes and 
still allowed deadlocks, it would definitely merit a warning.

----------
nosy: +josh.r

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33319>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to