mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.12] gh-107219: Fix concurrent.futures terminate_broken() (GH-109244) (#109254)
gh-107219: Fix concurrent.futures terminate_broken() (GH-109244)
Fix a race condition in concurrent.futures. When a process in the
process pool was terminated abruptly (while the future was running or
pending), close the connection write end. If the call queue is
blocked on sending bytes to a worker process, closing the connection
write end interrupts the send, so the queue can be closed.
Changes:
* _ExecutorManagerThread.terminate_broken() now closes
call_queue._writer.
* multiprocessing PipeConnection.close() now interrupts
WaitForMultipleObjects() in _send_bytes() by cancelling the
overlapped operation.
(cherry picked from commit a9b1f84790
)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
3e1c9e8264
commit
1d8c18c39d
3 changed files with 27 additions and 0 deletions
|
@ -503,6 +503,10 @@ class _ExecutorManagerThread(threading.Thread):
|
|||
# https://github.com/python/cpython/issues/94777
|
||||
self.call_queue._reader.close()
|
||||
|
||||
# gh-107219: Close the connection writer which can unblock
|
||||
# Queue._feed() if it was stuck in send_bytes().
|
||||
self.call_queue._writer.close()
|
||||
|
||||
# clean up resources
|
||||
self.join_executor_internals()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue