title: Python - parallel commands
body: <p>How do I run several python commands in parallel in a python script ? As a simple example I have several sleep commands:</p>
  
  <pre><code>time.sleep(4)
  time.sleep(6)
  time.sleep(8)
  </code></pre>
  
  <p>I want all the above to be executed in parallel. I expect the control back when 8 seconds have passed (which is the max of all the sleeps above).
  The real commands will be different but want to get an idea with above.</p>
  
  <p>In bash, I could have simple done:</p>
  
  <pre><code>sleep 4 &amp;
  pid1=$!
  sleep 6 &amp;
  pid2=$!
  sleep 8 &amp;
  pid3=$!
  wait $pid1 $pid2 $pid3
  </code></pre>
  
  <p>Thanks.</p>