]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-80184: Set getattr(socket, "SOMAXCONN", 5) as the default queue size for TCPServer...
authorSahil Shah <sahildshah1@gmail.com>
Mon, 19 May 2025 19:28:09 +0000 (15:28 -0400)
committerGitHub <noreply@github.com>
Mon, 19 May 2025 19:28:09 +0000 (19:28 +0000)
socketserver.TCPServer default queue size becomes SOMAXCONN instead of 5 when possible.

Doc/library/socketserver.rst
Lib/socketserver.py
Misc/NEWS.d/next/Library/2025-05-19-17-27-21.gh-issue-80184.LOkbaw.rst [new file with mode: 0644]

index 59cfa136a3b7da9a93441c2d7e99463d1c2054f8..753f12460b824b84fea0bb098350a6a920a116ec 100644 (file)
@@ -24,6 +24,8 @@ There are four basic concrete server classes:
    :meth:`~BaseServer.server_activate`.  The other parameters are passed to
    the :class:`BaseServer` base class.
 
+   .. versionchanged:: next
+      The default queue size is now ``socket.SOMAXCONN`` for :class:`socketserver.TCPServer`.
 
 .. class:: UDPServer(server_address, RequestHandlerClass, bind_and_activate=True)
 
index 35b2723de3babe41b72e53bb2c56584628b6ce39..93b0a23be27f6808645b344c383336841eb8a20b 100644 (file)
@@ -441,7 +441,7 @@ class TCPServer(BaseServer):
 
     socket_type = socket.SOCK_STREAM
 
-    request_queue_size = 5
+    request_queue_size = getattr(socket, "SOMAXCONN", 5)
 
     allow_reuse_address = False
 
diff --git a/Misc/NEWS.d/next/Library/2025-05-19-17-27-21.gh-issue-80184.LOkbaw.rst b/Misc/NEWS.d/next/Library/2025-05-19-17-27-21.gh-issue-80184.LOkbaw.rst
new file mode 100644 (file)
index 0000000..089268d
--- /dev/null
@@ -0,0 +1 @@
+The default queue size is now ``socket.SOMAXCONN`` for :class:`socketserver.TCPServer`.