With subprocess.Popen(, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc1, \
The threading module allows us to do that.įirst, have a look at how to do the output redirection part alone in this question: Python Popen: Write to stdout AND log file simultaneously For example, I wanted to launch two processes that talk over a port between them, and save their stdout to a log file and stdout.
However, there are cases where you need this.
Both capture output and run on background with threadingĪs mentioned on this answer, if you capture the output with stdout= and then try to read(), then the process blocks.