0

I created a batch file for software build. I have different "cmd" commands to build the project for different platforms. The build for the project will take time (around 2 minutes for each) to execute and complete.

I want to build both the projects in parallel to save time rather than executing it one by one in sequence. Do I need to create a thread to execute both the command in parallel? I put both the command in batch (.bat) file and it is executing both the command one by one in sequence at the moment.

Example: full_build.bat

clean plat1 build plat1
clean plat2 build plat2

Referred SE Questions

kapilddit
  • 1,729
  • 4
  • 26
  • 51
  • I open, two different command windows and executing different scripts in each window. Need to check dependency of both the script in accessing the common files. – kapilddit Oct 30 '19 at 06:23
  • 1
    use the [start](https://ss64.com/nt/start.html) command to run them in their own processes. – Stephan Oct 30 '19 at 08:19

1 Answers1

1

You can build a cute little python script that does what you want to do. You thread the script and then use the system interface to run the command prompt execution of the batch file in both at the same time.

I took a moment to write you a little easy implementation. it should run fine.

import subprocess
import threading
run_command(nameofscript):
    subprocess.call("windowswayofrunning nameofscript"); 

if __name__ == "__main__": 
    # creating thread 
    t1 = threading.Thread(target=run_command, args=("script1",)) 
    t2 = threading.Thread(target=print_cube, args=("script2",)) 

    # starting thread 1 
    t1.start() 
    # starting thread 2 
    t2.start() 

    # wait until thread 1 is completely executed 
    t1.join() 
    # wait until thread 2 is completely executed 
    t2.join() 

    # both threads completely executed 
    print("Done!") 

goes without saying this would work on any language that has this ability.

Rozar Natrim
  • 133
  • 1
  • 9