Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python subprocess.popen() without waiting

I'm using Python 3.4.2 on Windows. In script1.py I'm doing this:

myProc = subprocess.Popen([sys.executable, "script2.py", "argument"])
myProc.communicate()

it works and call script2.py . The problem is that in script2.py there is a infinite loop (there must be) and the script1.py is waiting for script2.py to finish. How can I tell to script1.py to just call script2.py and don't wait for the process to finish?

like image 533
jul Avatar asked Jan 30 '15 09:01

jul


1 Answers

Just don't call myProc.communicate() if you don't want to wait. subprocess.Popen will start the process.

like image 105
mavroprovato Avatar answered Sep 19 '22 19:09

mavroprovato