Python 3.5 introduced the run()
function in the subprocess
module as the new recommended high-level means of subprocess invocation.
Amongst the three older (available since Python 2.5 / 2.7) high-level API functions is check_call()
. The Python 3.5 documentation claims that check_call()
[...] is equivalent to:
run(..., check=True)
The documentation also warns against passing subprocess.PIPE
as stdout
or stderr
to check_call()
:
Note
Do not use
stdout=PIPE
orstderr=PIPE
with this function. The child process will block if it generates enough output to a pipe to fill up the OS pipe buffer as the pipes are not being read from.
As it's "equivalent", does this warning also apply to run(..., check=True)
, i.e., should
subprocess.run(..., stdout=subprocess.PIPE, check=True)
and
subprocess.run(..., stderr=subprocess.PIPE, check=True)
be avoided, too? (The documentation of run()
doesn't mention this caveat.)