avoid piping subprocess command output when not waiting for results

This commit is contained in:
Blake Harnden 2020-06-04 21:14:11 -07:00
parent 7b2dd59c81
commit eaa05c34ba

View file

@ -228,7 +228,8 @@ def cmd(
if shell is False:
args = shlex.split(args)
try:
p = Popen(args, stdout=PIPE, stderr=PIPE, env=env, cwd=cwd, shell=shell)
output = PIPE if wait else DEVNULL
p = Popen(args, stdout=output, stderr=output, env=env, cwd=cwd, shell=shell)
if wait:
stdout, stderr = p.communicate()
stdout = stdout.decode("utf-8").strip()