August 16th, 2013, 05:08 PM
-
Spawn 2 python scripts at same time in windows
Hi All,
I have 2 python scripts and successfully executes when run in sequential, but i am looking to have 1 master script which will execute 2 scripts at the same time, gather results from 2 scripts into a master script.
Could some one please help me to achieve this?
Regards,
Raj
August 17th, 2013, 02:11 PM
-
What you're describing is a multi-threaded application , in which you will be launching two scripts in their own threads and then retreiving the results asynchronously. I don't do a lot of this kind of programming, but the place you want to start reading is here:
http://docs.python.org/2/library/threading.html
Your "master" script is going to have to create two threads, start them, and then wait for each to complete.
August 17th, 2013, 09:00 PM
-
multi-processing is another way to go.
I'd write a shell script to launch the programs or submit them to the batch queue. In unix,
python p1.py &
python p2.py &
In DOS, (except that you'd need to look up the command) but effectively,
start /nowait python p1.py
start /nowait python p2.py
[code]
Code tags[/code] are essential for python code and Makefiles!