]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-101225: Increase the socket backlog when creating a multiprocessing.connect...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 14 Jan 2024 15:29:15 +0000 (16:29 +0100)
committerGitHub <noreply@github.com>
Sun, 14 Jan 2024 15:29:15 +0000 (16:29 +0100)
gh-101225: Increase the socket backlog when creating a multiprocessing.connection.Listener (GH-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 c7d59bd8cfa053e77ae3446c82afff1fd38a4886)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Lib/multiprocessing/managers.py
Lib/multiprocessing/resource_sharer.py
Misc/NEWS.d/next/Library/2023-12-29-17-46-06.gh-issue-101225.QaEyxF.rst [new file with mode: 0644]

index b6534939b4d98bc8f39cdb0750af08d7ea649f1a..75d9c18c201a86da3b3c2eaede426dace711c701 100644 (file)
@@ -153,7 +153,7 @@ class Server(object):
         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, ())}
index 66076509a1202e7a1b4d8a481f64621a4bfbbf3e..b8afb0fbed3a3c2c31d1c1a567a135c8d34c4e40 100644 (file)
@@ -123,7 +123,7 @@ class _ResourceSharer(object):
         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
diff --git a/Misc/NEWS.d/next/Library/2023-12-29-17-46-06.gh-issue-101225.QaEyxF.rst b/Misc/NEWS.d/next/Library/2023-12-29-17-46-06.gh-issue-101225.QaEyxF.rst
new file mode 100644 (file)
index 0000000..ab3c3a5
--- /dev/null
@@ -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.