]> granicus.if.org Git - python/commitdiff
Issue #12364: Fix a hang in concurrent.futures.ProcessPoolExecutor.
authorRoss Lagerwall <rosslagerwall@gmail.com>
Sun, 8 Jan 2012 06:29:40 +0000 (08:29 +0200)
committerRoss Lagerwall <rosslagerwall@gmail.com>
Sun, 8 Jan 2012 06:29:40 +0000 (08:29 +0200)
Lib/concurrent/futures/process.py
Lib/test/test_concurrent_futures.py
Misc/NEWS

index 80829406774a7e85b9d64ac18d01c22a55b3dacc..d3bbe2c5e68f5534bb47b97f075c3350e8eee4d8 100644 (file)
@@ -213,9 +213,7 @@ def _queue_management_worker(executor_reference,
                 work_item.future.set_exception(result_item.exception)
             else:
                 work_item.future.set_result(result_item.result)
-            continue
-        # If we come here, we either got a timeout or were explicitly woken up.
-        # In either case, check whether we should start shutting down.
+        # Check whether we should start shutting down.
         executor = executor_reference()
         # No more work items can be added if:
         #   - The interpreter is shutting down OR
@@ -234,9 +232,6 @@ def _queue_management_worker(executor_reference,
                     p.join()
                 call_queue.close()
                 return
-            else:
-                # Start shutting down by telling a process it can exit.
-                shutdown_one_process()
         del executor
 
 _system_limits_checked = False
index 6cc57f85d0b7f46bc6d7ee408785fa0ac5169d1d..372da27dca398da0ba4c6827a4666e1356a2bcdc 100644 (file)
@@ -109,6 +109,12 @@ class ExecutorShutdownTest(unittest.TestCase):
         self.assertFalse(err)
         self.assertEqual(out.strip(), b"apple")
 
+    def test_hang_issue12364(self):
+        fs = [self.executor.submit(time.sleep, 0.1) for _ in range(50)]
+        self.executor.shutdown()
+        for f in fs:
+            f.result()
+
 
 class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest):
     def _prime_executor(self):
index 9212f9e622932792abe2324914ab4bb0a16deacd..8e95abb6183e2ebc92115d797b478d827288b973 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -97,6 +97,10 @@ Core and Builtins
 Library
 -------
 
+- Issue #12364: Fix a hang in concurrent.futures.ProcessPoolExecutor.
+  The hang would occur when retrieving the result of a scheduled future after
+  the executor had been shut down.
+
 - Issue #13502: threading: Fix a race condition in Event.wait() that made it
   return False when the event was set and cleared right after.