title: Using Python subprocess to run SLURM script to submit multiple long jobs to queue and waiting for jobs to finish before continuing python script
body: <p>Basics of the situation are that I'm using Python's <code>subprocess</code> module to run a SLURM script which submits a number of jobs to a queue on some HPC resources that I use. I would like the Python script to wait until all the jobs submitted are finished. I tried doing this with:</p>
  
  <pre><code>proc = subprocess.Popen(['sbatch slurm.sh'],shell=True)
  proc.wait()
  </code></pre>
  
  <p>However, it only waits for the jobs to be submitted and not for all the jobs to finish. Anyone have any suggestions for how to make this work? </p>
  
  <p>Note: One idea I had was potentially having subprocess communicate somehow with the .out file produced by the SLURM script (and wait for that to finish being edited maybe?), but I'm not sure how that would work.</p>
  
  <p>Thanks for any ideas!</p>