Reputation: 1769
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
Upvotes: 0
Views: 587
Reputation: 153
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.
Upvotes: 1