title: Concurrent futures submit task to process pool non-blockingly
body: <p>This question is Python 2-specific, using the community maintained backport of <code>concurrent.futures</code>.</p>
  
  <p>I'm trying to use a ProcessPoolExecutor (with maxWorkers trivially set to 2) to run two tasks in parallel. Those tasks are both Python functions, and I'd like each of them to run in their own process. They don't need to coordinate with each other (I don't even need to know the exit status). I just want to be able to launch processes simultaneously and limit the number of processes that run in parallel at any given moment in time.</p>
  
  <pre><code>import concurrent.futures as futures
  import time
  
  
  def do_stuff(name):
      for x in range(10):
          print name, x
          time.sleep(1)
  
  
  pool = futures.ProcessPoolExecutor(max_workers=2)
  pool.submit(do_stuff("a"))
  print "a submitted!"
  pool.submit(do_stuff("b"))
  </code></pre>
  
  <p>This, however, prints</p>
  
  <p><code>
  a 0
  a 1
  ...
  a 9
  a submitted!
  b 0
  b 1
  ...
  b 9
  </code></p>
  
  <p>Why is <code>submit</code> a blocking operation? Is there a nonblocking equivalent?</p>
  
  <p>Here's an example using the <code>multiprocessing</code> library that has the behavior I want. It starts each process nonblockingly and then calls <code>join</code> (which is presumably just a thin wrapper around <code>waitpid(2)</code>). However, this technique does not give me the ability to limit the number of processes that run in parallel at any given moment.</p>
  
  <pre><code>import multiprocessing
  import time
  
  
  def do_stuff(name):
      for x in range(10):
          print name, x
          time.sleep(1)
  
  
  proc_a = multiprocessing.Process(target=do_stuff, args="a")
  proc_b = multiprocessing.Process(target=do_stuff, args="b")
  proc_a.start()
  proc_b.start()
  proc_a.join()
  proc_b.join()
  </code></pre>