Skip to content

Commit b713adf

Browse files
authored
bpo-31326: ProcessPoolExecutor waits for the call queue thread (#3265)
* bpo-31326: ProcessPoolExecutor waits for the call queue thread concurrent.futures.ProcessPoolExecutor.shutdown() now explicitly closes the call queue. Moreover, shutdown(wait=True) now also join the call queue thread, to prevent leaking a dangling thread. * Fix for shutdown() being called twice.
1 parent 97e1b1c commit b713adf

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Lib/concurrent/futures/process.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,11 @@ def shutdown(self, wait=True):
507507
# To reduce the risk of opening too many files, remove references to
508508
# objects that use file descriptors.
509509
self._queue_management_thread = None
510-
self._call_queue = None
510+
if self._call_queue is not None:
511+
self._call_queue.close()
512+
if wait:
513+
self._call_queue.join_thread()
514+
self._call_queue = None
511515
self._result_queue = None
512516
self._processes = None
513517
shutdown.__doc__ = _base.Executor.shutdown.__doc__
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
concurrent.futures.ProcessPoolExecutor.shutdown() now explicitly closes the
2+
call queue. Moreover, shutdown(wait=True) now also join the call queue
3+
thread, to prevent leaking a dangling thread.

0 commit comments

Comments
 (0)