Invoke an independent, non-blocking process from Python 3.6?

jladasky at itu.edu jladasky at itu.edu
Mon Mar 26 23:32:06 EDT 2018


On Monday, March 26, 2018 at 5:45:40 PM UTC-7, Chris Angelico wrote:
> On Tue, Mar 27, 2018 at 11:18 AM,  <j...y at itu.edu> wrote:
> > I have used multiprocessing before when I wrote some parallelized code.  That program required significant communication between processes, and it's overkill for my purpose here.  I don't need communication between the spawning (live data) program and the spawned program.  In fact, to the extent that the live data program has to pay attention to anything besides the data stream, I think it could be bad.
> >
> > I have been investigating the subprocess module.  I'm looking for something which behaves like subprocess.run("python3 my_program.py"), but which does not "Wait for command to complete, then return a CompletedProcess instance."
> >
> As far as I know, subprocess.run() will always wait for the process to
> complete. But you can use the Popen constructor.

Thank you Chris, subprocess.Popen worked nicely for me.  I had to set shell=True to make it work, but it did work.  All parts of my program now operate independently and crash-free!



More information about the Python-list mailing list