title: multiprocessing threadpool not terminating as expected
body: <p>I'm running Python 3.4 on Windows 7.</p>
  
  <p>I'm trying to understand more about multiprocessing, and doing so by trying to write a function that performs a clean little timeout on another function call.  But I've run into a problem I can't figure out.</p>
  
  <p>According to the Python docs on Multiprocessing:</p>
  
  <blockquote>
    <p>Terminate() "Stops the worker processes immediately without completing outstanding work."</p>
  </blockquote>
  
  <p>However, when I test this, <code>pool.terminate()</code> seems to wait for the worker processes to finish instead of killing them!</p>
  
  <p>So when I run this code:</p>
  
  <pre><code>import multiprocessing.pool
  from time import sleep
  
  def timeout(seconds, function, *args, **kwargs):
  
      pool = multiprocessing.pool.ThreadPool(processes = 1)
      result = pool.apply_async(function, args, kwargs)
  
      try: result.get(seconds)
      except multiprocessing.context.TimeoutError:
          print("Process timed out")
          pool.terminate()
          pool.join()
          print("Pool terminated")
      finally:
          pool.close()
  
  def worker():
      for n in range(5):
          sleep(1)
          print(n+1)
      print("Process succeeded")
  
  timeout(2.5, worker)
  </code></pre>
  
  <p>I expect the result to be this:</p>
  
  <pre class="lang-none prettyprint-override"><code>1
  2
  Process timed out
  Pool terminated
  </code></pre>
  
  <p>But instead I get this:</p>
  
  <pre class="lang-none prettyprint-override"><code>1
  2
  Process timed out
  3
  4
  5
  Process succeeded
  Pool terminated
  </code></pre>
  
  <p>I know that <code>result.get</code> raised the <code>TimeoutError</code> because the message "Process timed out" printed successfully.  And I know that <code>pool.terminate()</code> was called for the same reason, it just didn't seem to do anything!</p>
  
  <p>I feel like there is something here that I'm just not understanding. Can someone please help me out?</p>