]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-120485: Add an override of `allow_reuse_port` on classes subclassing `socketserver...
authorIdan Kapustian <71190257+idankap@users.noreply.github.com>
Sun, 16 Jun 2024 12:15:03 +0000 (15:15 +0300)
committerGitHub <noreply@github.com>
Sun, 16 Jun 2024 12:15:03 +0000 (13:15 +0100)
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Lib/http/server.py
Lib/logging/config.py
Lib/test/test_logging.py
Lib/xmlrpc/server.py
Misc/NEWS.d/next/Core and Builtins/2024-06-14-07-52-00.gh-issue-120485.yy4K4b.rst [new file with mode: 0644]

index 7d0da5052d2d4d57f0e10b394023b4d08124fb9f..2d010649e56b518ae91523b3b03f56025fbf15f2 100644 (file)
@@ -129,7 +129,8 @@ DEFAULT_ERROR_CONTENT_TYPE = "text/html;charset=utf-8"
 
 class HTTPServer(socketserver.TCPServer):
 
-    allow_reuse_address = 1    # Seems to make sense in testing environment
+    allow_reuse_address = True    # Seems to make sense in testing environment
+    allow_reuse_port = True
 
     def server_bind(self):
         """Override server_bind to store the server name."""
index 9de84e527b18acdedf732e065f7ae566cb8df41b..d2f23e53f35c5702a6ac276a3e81857678d610df 100644 (file)
@@ -984,7 +984,8 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT, verify=None):
         A simple TCP socket-based logging config receiver.
         """
 
-        allow_reuse_address = 1
+        allow_reuse_address = True
+        allow_reuse_port = True
 
         def __init__(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT,
                      handler=None, ready=None, verify=None):
index 504862ad53395e6cdcac641b55110eaf9d1ea5b8..5192ce252a4d4c17367b01427b504eb0b597e5a0 100644 (file)
@@ -1038,6 +1038,7 @@ class TestTCPServer(ControlMixin, ThreadingTCPServer):
     """
 
     allow_reuse_address = True
+    allow_reuse_port = True
 
     def __init__(self, addr, handler, poll_interval=0.5,
                  bind_and_activate=True):
index 4dddb1d10e08bd9b6eb8e70a3bced2c8c9cdbde5..90a356fbb8eae4575d053a75796f6958e7e682ee 100644 (file)
@@ -578,6 +578,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer,
     """
 
     allow_reuse_address = True
+    allow_reuse_port = True
 
     # Warning: this is for debugging purposes only! Never set this to True in
     # production code, as will be sending out sensitive information (exception
diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-06-14-07-52-00.gh-issue-120485.yy4K4b.rst b/Misc/NEWS.d/next/Core and Builtins/2024-06-14-07-52-00.gh-issue-120485.yy4K4b.rst
new file mode 100644 (file)
index 0000000..f41c233
--- /dev/null
@@ -0,0 +1 @@
+Add an override of ``allow_reuse_port`` on classes subclassing ``socketserver.TCPServer`` where ``allow_reuse_address`` is also overridden.