When I start a Popen with PIPE stdout, the process doesn't exit untill I press Enter
(Windows OS, tested with multiple python
and lxc
versions)
e.g.:
import subprocess as sp
cmd = ['lxc', 'exec', 'remote:container', '--', 'echo', '1']
with sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE) as proc:
while True:
print(proc.poll())
prints None None None... (proc.poll() == None when the process is still running) and when I press Enter
it immediately exits.
The process itself does it's job, nothing wrong there, only this exiting problem. It probably lies within the scope of the utility I'm calling (lxc
) but is there something I can do to debug this or to circumvent it from the python code?
This call works when it is called during a py.test
run, when py.test
captures all output, maybe I can do something similar to what it does?