Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.12] gh-114440: Close writer pipe in multiprocessing.Queue, not concurrent.futures #114489

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Lib/concurrent/futures/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,6 @@ def _terminate_broken(self, cause):

self.call_queue._terminate_broken()

# gh-107219: Close the connection writer which can unblock
# Queue._feed() if it was stuck in send_bytes().
if sys.platform == 'win32':
self.call_queue._writer.close()

# clean up resources
self._join_executor_internals(broken=True)

Expand Down
5 changes: 5 additions & 0 deletions Lib/multiprocessing/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ def _terminate_broken(self):
# gh-94777: Prevent queue writing to a pipe which is no longer read.
self._reader.close()

# gh-107219: Close the connection writer which can unblock
# Queue._feed() if it was stuck in send_bytes().
if sys.platform == 'win32':
self._writer.close()

self.close()
self.join_thread()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
On Windows, closing the connection writer when cleaning up a broken
:class:`multiprocessing.Queue` queue is now done for all queues, rather than
only in :mod:`concurrent.futures` manager thread.
This can prevent a deadlock when a ``multiprocessing`` worker process terminates
without cleaning up.
This completes the backport of patches by Victor Stinner and Serhiy Storchaka.
Loading