Skip to content

[3.11] gh-101225: Increase the socket backlog when creating a multiprocessing.connection.Listener (GH-113567) #114019

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

Merged
merged 2 commits into from
Jan 14, 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
2 changes: 1 addition & 1 deletion Lib/multiprocessing/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def __init__(self, registry, address, authkey, serializer):
Listener, Client = listener_client[serializer]

# do authentication later
self.listener = Listener(address=address, backlog=16)
self.listener = Listener(address=address, backlog=128)
self.address = self.listener.address

self.id_to_obj = {'0': (None, ())}
Expand Down
2 changes: 1 addition & 1 deletion Lib/multiprocessing/resource_sharer.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _start(self):
from .connection import Listener
assert self._listener is None, "Already have Listener"
util.debug('starting listener and thread for sending handles')
self._listener = Listener(authkey=process.current_process().authkey)
self._listener = Listener(authkey=process.current_process().authkey, backlog=128)
self._address = self._listener.address
t = threading.Thread(target=self._serve)
t.daemon = True
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Increase the backlog for :class:`multiprocessing.connection.Listener` objects created
by :mod:`multiprocessing.manager` and :mod:`multiprocessing.resource_sharer` to
significantly reduce the risk of getting a connection refused error when creating
a :class:`multiprocessing.connection.Connection` to them.