thraxil.org:

Reply to: Subprocess Hanging: PIPE is your enemy

Thanks for writing the best post on this topic.

My situation was to calling external program on large number of files, which chokes the pipe very quickly. I've tried:

  1. stdout=subprocess.PIPE, stderr=subprocess.STDOUT
  2. using a temp file object for stdout and stderr
  3. shell = True or False
  4. lots of variants of Popen(), check_output(), and call().

None worked!

My solution in the end was to use the default stdout and stderr of call(), namely None by Python 3.7.2.

In other words, don't bother with a full list of arguments, simply:

completed = subprocess.call(cmd, shell=True)

That's it!


formatting is with Markdown syntax. Comments are not displayed until they are approved by a moderator. Moderators will not approve unless the comment contributes value to the discussion.

namerequired
emailrequired
url
remember info?