Commit d06a065a authored by Antoine Pitrou's avatar Antoine Pitrou

Fix potential resource leaks in concurrent.futures.ProcessPoolExecutor

by joining all queues and processes when shutdown() is called.
parent db535957
...@@ -209,6 +209,8 @@ def _queue_management_worker(executor_reference, ...@@ -209,6 +209,8 @@ def _queue_management_worker(executor_reference,
# some multiprocessing.Queue methods may deadlock on Mac OS X. # some multiprocessing.Queue methods may deadlock on Mac OS X.
for p in processes.values(): for p in processes.values():
p.join() p.join()
# Release resources held by the queue
call_queue.close()
while True: while True:
_add_call_item_to_queue(pending_work_items, _add_call_item_to_queue(pending_work_items,
...@@ -246,7 +248,8 @@ def _queue_management_worker(executor_reference, ...@@ -246,7 +248,8 @@ def _queue_management_worker(executor_reference,
# Clean shutdown of a worker using its PID # Clean shutdown of a worker using its PID
# (avoids marking the executor broken) # (avoids marking the executor broken)
assert shutting_down() assert shutting_down()
del processes[result_item] p = processes.pop(result_item)
p.join()
if not processes: if not processes:
shutdown_worker() shutdown_worker()
return return
......
...@@ -634,7 +634,8 @@ def test_main(): ...@@ -634,7 +634,8 @@ def test_main():
ThreadPoolAsCompletedTests, ThreadPoolAsCompletedTests,
FutureTests, FutureTests,
ProcessPoolShutdownTest, ProcessPoolShutdownTest,
ThreadPoolShutdownTest) ThreadPoolShutdownTest,
)
finally: finally:
test.support.reap_children() test.support.reap_children()
......
...@@ -228,6 +228,9 @@ Core and Builtins ...@@ -228,6 +228,9 @@ Core and Builtins
Library Library
------- -------
- Fix potential resource leaks in concurrent.futures.ProcessPoolExecutor
by joining all queues and processes when shutdown() is called.
- Issue #11603: Fix a crash when __str__ is rebound as __repr__. Patch by - Issue #11603: Fix a crash when __str__ is rebound as __repr__. Patch by
Andreas Stührk. Andreas Stührk.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment