Skip to content

Commit

Permalink
pythongh-120485: Add an override of allow_reuse_port on classes sub…
Browse files Browse the repository at this point in the history
…classing `socketserver.TCPServer` (pythonGH-120488)

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
  • Loading branch information
2 people authored and mrahtz committed Jun 30, 2024
1 parent 8677c6a commit a5c986a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Lib/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,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."""
Expand Down
3 changes: 2 additions & 1 deletion Lib/logging/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,8 @@ class ConfigSocketReceiver(ThreadingTCPServer):
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):
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions Lib/xmlrpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add an override of ``allow_reuse_port`` on classes subclassing ``socketserver.TCPServer`` where ``allow_reuse_address`` is also overridden.

0 comments on commit a5c986a

Please sign in to comment.