1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Rep Power

    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?

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Rep Power
    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:


    Your "master" script is going to have to create two threads, start them, and then wait for each to complete.
  4. #3
  5. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    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!

IMN logo majestic logo threadwatch logo seochat tools logo