I have two python scripts script1.py
and script2.py
. While running the script, each script has more than 5 arguments in form of .csv, .txt etc
. 'argparse'
is used when the script is ran individually to get the arguments. How can I execute the two commands concurrently in python3.6. Say the first command is 'script1.py -i file1.csv -t file2.txt'
and second is 'script2.py -i file3.csv -t file4.txt"
. By running concurrently I wanted to reduce the run time. Following is what I have tried.
import subprocess
import time
start_time = time.time()
subprocess.run("script1.py -i file1.csv -t file2.txt & script2.py -i file3.csv -t file4.txt", shell = True)
print("Time in seconds %s " % (time.time() - start_time))
file1.csv and file3.csv are unequal split of file_x.csv. Since I am concerned about the execution time for data file with split and without split, I tried same script with single data (merged data file) file "file_x.csv" to see if execution time in both cases. To my surprise merged one (file_x.csv) took lesser time than the split one. So can someone help me to figure out the right way to run the code concurrently.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…