title: How to execute multiple bash commands in parallel in python
body: <p>So, I have a code which takes in input and starts a spark job in cluster.. So, something like</p>
  
  <pre><code>spark-submit driver.py -i input_path
  </code></pre>
  
  <p>Now, I have list of paths and I want to execute all these simulatenously..</p>
  
  <p>Here is what I tried</p>
  
  <pre><code>base_command = 'spark-submit driver.py -i %s'
  for path in paths:
     command = base_command%path
      subprocess.Popen(command, shell=True)
  </code></pre>
  
  <p>My hope was, all of the shell commands would be executed simultaneously but instead, I am noticing that it executes one command at a time.. </p>
  
  <p>How do i execute all the bash commands simultaneously.
  Thanks</p>