Skip to content

Commit 2aea0e9

Browse files
miss-islingtonronaldoussorenAA-Turner
authored
[3.12] pythongh-101225: Increase the socket backlog when creating a multiprocessing.connection.Listener (pythonGH-113567) (python#114018)
pythongh-101225: Increase the socket backlog when creating a multiprocessing.connection.Listener (pythonGH-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. (cherry picked from commit c7d59bd) Co-authored-by: Ronald Oussoren <[email protected]> Co-authored-by: Adam Turner <[email protected]>
1 parent fa7d8e9 commit 2aea0e9

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Lib/multiprocessing/managers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def __init__(self, registry, address, authkey, serializer):
153153
Listener, Client = listener_client[serializer]
154154

155155
# do authentication later
156-
self.listener = Listener(address=address, backlog=16)
156+
self.listener = Listener(address=address, backlog=128)
157157
self.address = self.listener.address
158158

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

Lib/multiprocessing/resource_sharer.py

+1-1
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
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)