8000 gh-101225: Increase the socket backlog when creating a multiprocessin… · python/cpython@c7d59bd · GitHub
[go: up one dir, main page]

Skip to content

Commit c7d59bd

Browse files
gh-101225: Increase the socket backlog when creating a multiprocessing.connection.Listener (#113567)
Increase the backlog for multiprocessing.connection.Listener` objects created by `multiprocessing.manager` and `multiprocessing.resource_sharer` to significantly reduce the risk of getting a connection refused error when creating a `multiprocessing.connection.Connection` to them.
1 parent 21f83ef commit c7d59bd

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Lib/multiprocessing/managers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def __init__(self, registry, address, authkey, serializer):
156156
Listener, Client = listener_client[serializer]
157157

158158
# do authentication later
159-
self.listener = Listener(address=address, backlog=16)
159+
self.listener = Listener(address=address, backlog=128)
160160
self.address = self.listener.address
161161

162162
self.id_to_obj = {'0': (None, ())}

Lib/multiprocessing/resource_sharer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def _start(self):
123123
from .connection import Listener
124124
assert self._listener is None, "Already have Listener"
125125
util.debug('starting listener and thread for sending handles')
126-
self._listener = Listener(authkey=process.current_process().authkey)
126+
self._listener = Listener(authkey=process.current_process().authkey, backlog=128)
127127
self._address = self._listener.address
128128
t = threading.Thread(target=self._serve)
129129
t.daemon = True
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Increase the backlog for :class:`multiprocessing.connection.Listener` objects created
2+
by :mod:`multiprocessing.manager` and :mod:`multiprocessing.resource_sharer` to
3+
significantly reduce the risk of getting a connection refused error when creating
4+
a :class:`multiprocessing.connection.Connection` to them.

0 commit comments

Comments
 (0)
0