In #30072 there was a change to socketserver.TCPServer which added a new variable allow_reuse_port to support the usage of SO_REUSEPORT along with SO_REUSEADDR. The problem is that the classes which inherit from socketserver.TCPServer and override allow_reuse_address weren't updated to include the override of the new variable allow_reuse_port.
If we set SO_REUSEPORT to True, one server like a HTTP server or a XMLRPC Server can bind to the same port, for example, localhost:1234. And the kernel may dispatch the request to different server process randomly.
This is a perplexing behavior to people who didn't know about it, for example, when a user started a HTTP service process when develop a new website, and modified the source code, and forgot there was already a process there, then started a new one. As a result, he will see his change works randomly.
So I think it's not a good idea to set the SO_REUSEPORT on as default.
Activity
aisk commented on Jun 14, 2024
If we set SO_REUSEPORT to True, one server like a HTTP server or a XMLRPC Server can bind to the same port, for example, localhost:1234. And the kernel may dispatch the request to different server process randomly.
This is a perplexing behavior to people who didn't know about it, for example, when a user started a HTTP service process when develop a new website, and modified the source code, and forgot there was already a process there, then started a new one. As a result, he will see his change works randomly.
So I think it's not a good idea to set the SO_REUSEPORT on as default.
gh-120485: Add an override of `allow_reuse_port` on classes subclassi…
nineteendo commented on Jun 19, 2024
Can this be closed?
pythongh-120485: Add an override of `allow_reuse_port` on classes sub…
pythongh-120485: Add an override of `allow_reuse_port` on classes sub…
pythongh-120485: Add an override of `allow_reuse_port` on classes sub…
pythongh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP …
gh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP servers (
pythongh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP …
pythongh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP …
pythongh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP …
pythongh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP …
pythongh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP …
pythongh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP …