bpo-31326: ProcessPoolExecutor waits for the call queue thread (#3265) · python/cpython@b713adf

2 files changed

lines changed

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__

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.