I am trying to create 86 instances of task.py to run simultaneously.
import sys
import subprocess
for file in range(86):
subprocess.call([sys.executable,'task.py',str(file)+'in.csv',str(filen)+'out.csv'])
I am trying to create 86 instances of task.py to run simultaneously.
import sys
import subprocess
for file in range(86):
subprocess.call([sys.executable,'task.py',str(file)+'in.csv',str(filen)+'out.csv'])
subprocess.call waits for command to complete. Use subprocess.Popen instead:
import sys
import subprocess
procs = []
for i in range(86):
proc = subprocess.Popen([sys.executable, 'task.py', '{}in.csv'.format(i), '{}out.csv'.format(i)])
procs.append(proc)
for proc in procs:
proc.wait()
out =subprocess.Popen("hugo server -D", stdout = subprocess.PIPE) outputs.append(out) And then iterating through outputs and calling output.wait(). It opens up the first program, but then doesn't open up the next one unless I close the first program."hugo server -D" -> ['hugo', 'server', '-D']. If that does not work, please post a separate question so that others can answer you.