How to capture streaming output in python from subprocess.communicate()

后端 未结 2 654
执念已碎
执念已碎 2021-01-06 11:21

Currently, I have something like this:

self.process = subprocess.Popen(self.cmd, stdout=subprocess.PIPE)
out, err = self.process.communicate()
2条回答
  •  忘掉有多难
    2021-01-06 11:54

    The output goes to your calling process, essentially capturing the stdout from self.cmd, so that output does not go anywhere else.

    What you need to do is to print it from the 'parent' process if you want to see the output.

提交回复
热议问题