title: Python: Run multiple exe with load balance
body: <p>I'm trying to run multiple exe's (12 of them), because of computer resources I can spawn maximum 4 at a time before I get performance degradation.</p>
  
  <p>I'm trying to find if there is a way to call 4 exe's at a time and as soon as one of them finishes, to call another exe to fill the resources that have freed up</p>
  
  <p>My current code does this:</p>
  
  <pre><code>    excs = [r"path\to\exe\exe.exe",r"path\to\exe\exe.exe",r"path\to\exe\exe.exe",r"path\to\exe\exe.exe"]
  
      running = [subprocess.Popen(ex) for ex in excs]
  
      [process.wait() for process in running]
  </code></pre>
  
  <p>It repeats this process three times so that it runs all 12. Unfortunately it means that it needs to wait for all of them to finish before moving on to the next set. Is there a more efficient way of doing this? </p>
  
  <p>For the record, all of the exe's have different run times. </p>