(original) (raw)

changeset: 74299:26389e9efa9c branch: 3.2 parent: 74295:69527695eff8 user: Ross Lagerwall rosslagerwall@gmail.com date: Sun Jan 08 08:29:40 2012 +0200 files: Lib/concurrent/futures/process.py Lib/test/test_concurrent_futures.py Misc/NEWS description: Issue #12364: Fix a hang in concurrent.futures.ProcessPoolExecutor. diff -r 69527695eff8 -r 26389e9efa9c Lib/concurrent/futures/process.py --- a/Lib/concurrent/futures/process.py Sat Jan 07 18:34:07 2012 +0100 +++ b/Lib/concurrent/futures/process.py Sun Jan 08 08:29:40 2012 +0200 @@ -213,9 +213,7 @@ 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 @@ 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 diff -r 69527695eff8 -r 26389e9efa9c Lib/test/test_concurrent_futures.py --- a/Lib/test/test_concurrent_futures.py Sat Jan 07 18:34:07 2012 +0100 +++ b/Lib/test/test_concurrent_futures.py Sun Jan 08 08:29:40 2012 +0200 @@ -109,6 +109,12 @@ 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): diff -r 69527695eff8 -r 26389e9efa9c Misc/NEWS --- a/Misc/NEWS Sat Jan 07 18:34:07 2012 +0100 +++ b/Misc/NEWS Sun Jan 08 08:29:40 2012 +0200 @@ -97,6 +97,10 @@ 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. /rosslagerwall@gmail.com