Skip to content

Commit 192d17c

Browse files
idankapvsajip
andauthored
gh-120485: Add an override of allow_reuse_port on classes subclassing socketserver.TCPServer (GH-120488)
Co-authored-by: Vinay Sajip <[email protected]>
1 parent 0c0348a commit 192d17c

File tree

5 files changed

+7
-2
lines changed

5 files changed

+7
-2
lines changed

Lib/http/server.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@
129129

130130
class HTTPServer(socketserver.TCPServer):
131131

132-
allow_reuse_address = 1 # Seems to make sense in testing environment
132+
allow_reuse_address = True # Seems to make sense in testing environment
133+
allow_reuse_port = True
133134

134135
def server_bind(self):
135136
"""Override server_bind to store the server name."""

Lib/logging/config.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,8 @@ class ConfigSocketReceiver(ThreadingTCPServer):
984984
A simple TCP socket-based logging config receiver.
985985
"""
986986

987-
allow_reuse_address = 1
987+
allow_reuse_address = True
988+
allow_reuse_port = True
988989

989990
def __init__(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT,
990991
handler=None, ready=None, verify=None):

Lib/test/test_logging.py

+1
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,7 @@ class TestTCPServer(ControlMixin, ThreadingTCPServer):
10381038
"""
10391039

10401040
allow_reuse_address = True
1041+
allow_reuse_port = True
10411042

10421043
def __init__(self, addr, handler, poll_interval=0.5,
10431044
bind_and_activate=True):

Lib/xmlrpc/server.py

+1
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer,
578578
"""
579579

580580
allow_reuse_address = True
581+
allow_reuse_port = True
581582

582583
# Warning: this is for debugging purposes only! Never set this to True in
583584
# production code, as will be sending out sensitive information (exception
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add an override of ``allow_reuse_port`` on classes subclassing ``socketserver.TCPServer`` where ``allow_reuse_address`` is also overridden.

0 commit comments

Comments
 (0)