I am automating a GUI application that also has a CLI. I can successfully run the following (theApplication is an internally developed app):
import subprocess
process = subprocess.Popen(r'theApplication.exe -foo=7')
It then prints its output which I wish to process, so I use subprocess.PIPE
import subprocess
process = subprocess.Popen(r'theApplication.exe -foo=7', stdout=subprocess.PIPE)
Now the program does not start and Windows reports that theApplication has stopped working
. The same happens if the stdout is redirected to DEVNULL or a file. I tried setting bufsize
to 0 and 1 and the same happens.
Tried all permutations with stdout
and stderr
being redirected or not. It only works if neither of them is redirected. If one is redirected it instantly breaks the program. The value of process.returncode
is None
.
How can pipeing the output can break the program?