https://github.com/python/cpython/commit/6fa6a6180571d0928c3d867edd3ea0eb2ee0357c
commit: 6fa6a6180571d0928c3d867edd3ea0eb2ee0357c
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: ronaldoussoren <[email protected]>
date: 2024-01-14T16:29:30+01:00
summary:

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

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 <[email protected]>
Co-authored-by: Adam Turner <[email protected]>

files:
A Misc/NEWS.d/next/Library/2023-12-29-17-46-06.gh-issue-101225.QaEyxF.rst
M Lib/multiprocessing/managers.py
M Lib/multiprocessing/resource_sharer.py

diff --git a/Lib/multiprocessing/managers.py b/Lib/multiprocessing/managers.py
index 3f6479b7e3a693..245b15f227ae58 100644
--- a/Lib/multiprocessing/managers.py
+++ b/Lib/multiprocessing/managers.py
@@ -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, ())}
diff --git a/Lib/multiprocessing/resource_sharer.py 
b/Lib/multiprocessing/resource_sharer.py
index 66076509a1202e..b8afb0fbed3a3c 100644
--- a/Lib/multiprocessing/resource_sharer.py
+++ b/Lib/multiprocessing/resource_sharer.py
@@ -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
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
index 00000000000000..ab3c3a5ef23f45
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-12-29-17-46-06.gh-issue-101225.QaEyxF.rst
@@ -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.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to