title: python executor spawn tasks from done callback (recursively submit tasks)
body: <p>I'm trying to submit further tasks from result of a task that was done:</p>
  
  <pre><code>with concurrent.futures.ThreadPoolExecutor() as executor:
      future = executor.submit(my_task)
      def callback(future):
          for another_task in future.result():
              future = executor.submit(another_task)
              future.add_done_callback(callback)
      future.add_done_callback(callback)
  </code></pre>
  
  <p>but I'm getting:</p>
  
  <blockquote>
    <p>RuntimeError: cannot schedule new futures after shutdown</p>
  </blockquote>
  
  <p>What's the best way to make the executor hold for the callback? A semaphore?</p>
  
  <p>Ideally the solution should transfer well if <code>ThreadPoolExecutor</code> is replaced with <code>ProcessPoolExecutor</code>.</p>