title: ThreadPoolExecutor with Context Manager "cannot schedule new futures after shutdown"
body: <p>I'm creating a thread manager class that handles executing tasks as threads and passing the results to the next process step.  The flow works properly upon the first execution of receiving a task, but the second execution fails with the following error :</p>
  <pre><code>...python3.8/concurrent/futures/thread.py&quot;, line 179, in submit
  raise RuntimeError('cannot schedule new futures after shutdown')
  RuntimeError: cannot schedule new futures after shutdown
  </code></pre>
  <p>The tasks come from <code>Cmd.cmdloop</code> user input - so, the script is persistent and meant to not shutdown.  Instead, <code>run</code> will be called multiple times, as input is received from the user.</p>
  <p>I've implemented a <code>ThreadPoolExecutor</code> to handle the work load and trying to gather the results chronologically with <code>concurrent.futures.as_completed</code> so each item is processed to the next step in order of completion.</p>
  <p>The <code>run</code> method below works <b>perfect</b> for the first execution, but returns the error upon second execution of the same task (that succeeded during the first execution).</p>
  <pre><code>  def run ( self, _executor=None, _futures={}, ) -&gt; bool :
       
       task = self.pipeline.get( )
       
       with _executor or self.__default_executor as executor :
           
           _futures = { executor.submit ( task.target.execute, ), }
  
           for future in concurrent.futures.as_completed ( _futures, ) :
                       
               print( future.result ( ) )
                               
       return True
  </code></pre>
  <p>So, the idea is that each call to <code>run</code> will create and teardown the <code>executor</code> with the context.  But the error suggests the context shutdown properly after the first execution, and cannot be reopened/recreated when <code>run</code> is called during the second iteration... what is this error pointing to? .. what am I missing?</p>
  <p>Any help would be great - thanks in advance.</p>