Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some classes which inherit socketserver.TCPServer should override allow_reuse_port #120485

Closed
idankap opened this issue Jun 14, 2024 · 2 comments
Closed
Labels
type-bug An unexpected behavior, bug, or error

Comments

@idankap
Copy link
Contributor

idankap commented Jun 14, 2024

Bug report

Bug description:

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.

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Linked PRs

@aisk
Copy link
Member

aisk commented 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.

vsajip added a commit that referenced this issue Jun 16, 2024
…ng `socketserver.TCPServer` (GH-120488)

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
@nineteendo
Copy link
Contributor

Can this be closed?

@vsajip vsajip closed this as completed Jun 19, 2024
mrahtz pushed a commit to mrahtz/cpython that referenced this issue Jun 30, 2024
…classing `socketserver.TCPServer` (pythonGH-120488)

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
…classing `socketserver.TCPServer` (pythonGH-120488)

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
…classing `socketserver.TCPServer` (pythonGH-120488)

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants