I have a pyhton script submitting jobs to PBS through subprocess.run (or subprocess.Popen) like this
import subprocess as sp
some operations...
for j in range(njobs):
runfile = 'run' + str(j) + '.sh'
sp.run('qsub -W block=true ' + runfile + ' &',shell=True)
other operations depending on the results of the submitted job...
In the loop, all the jobs are submitted. Then, I need the python code to stop, waiting until all the jobs are completed, and then go ahead with the following operations. I'm able to do it in bash (just using the -W block=true option in qsub and then the command wait and it's done), but cannot find the right way in python
thanks
manuela
P.S. I tried using os.wait() (which I thought was similar to the wait bash command), then found sp.Popen.wait but actually did not undertand how it works