Skip to content

Running canned in a subprocess

Philipp Fehre edited this page Jul 1, 2015 · 1 revision

Running canned in a subprocess can cause problems. See this issue. If you run into this in python you can try as suggested in a comment

In case people are still running into this, here's how I solved it. Basically, if I didn't set a STDIN/STDOUT/STDERR for the Popen call, it seemed to work.

Startup.POPEN_CANNED = subprocess.Popen(['canned -p 3000 %s' % props.mockBase], shell=True, preexec_fn=os.setsid)

The POPEN_CANNED variable is just a static class variable to the returned Popen so that I can shutdown canned later with:

Startup.POPEN_CANNED.terminate()
Startup.POPEN_CANNED.wait()

Hope that helps.

Clone this wiki locally