GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use cythonized SO_REUSEPORT rather than the unwrapped native one. by ptribble · Pull Request #609 · MagicStack/uvloop

Conversation

@ptribble

@ptribble ptribble commented Jun 20, 2024

Copy link
Copy Markdown
Contributor

The code already detects (via hasattr) whether SO_REUSEPORT is available, setting has_SO_REUSEPORT, and creates a wrapped SO_REUSEPORT (via getattr). This change ensures it's that wrapped SO_REUSEPORT that's used, rather than the native C version (which may not exist).

Fixes #550

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mtelka reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@ptribble
Use cythonized SO_REUSEPORT rather than the unwrapped native one.
48d0b1e
Fixes MagicStack#550
mtelka
mtelka reviewed Jun 20, 2024
View reviewed changes
Comment thread uvloop/loop.pyx
@@ -1775,7 +1775,7 @@ cdef class Loop:
if reuse_address:
sock.setsockopt(uv.SOL_SOCKET, uv.SO_REUSEADDR, 1)

@mtelka mtelka Jun 20, 2024

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the same problem here with SO_REUSEADDR?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ptribble ptribble Jun 20, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No; the place to look is uvloop/includes/stdlib.pxi

cdef int has_IPV6_V6ONLY = hasattr(socket, 'IPV6_V6ONLY')
cdef int IPV6_V6ONLY = getattr(socket, 'IPV6_V6ONLY', -1)
cdef int has_SO_REUSEPORT = hasattr(socket, 'SO_REUSEPORT')
cdef int SO_REUSEPORT = getattr(socket, 'SO_REUSEPORT', 0)

Note that there's a check to see if the variable exists, and then a python definition of the variable with a default, guaranteeing it's defined. This is how the code handles platforms that don't have the constants defined. For other constants (such as SO_REUSEADDR) there's neither a check nor a python definition of the constant.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mtelka reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
fantix
fantix approved these changes Aug 15, 2024
View reviewed changes

@fantix fantix left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also drop the definition of uv.SO_REUSEPORT to prevent future usage.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
fantix added 2 commits August 15, 2024 16:14
@fantix
Merge branch 'master' into fix-soreuseport
0012a6e
@fantix
Drop uv.SO_REUSEPORT
91bf31e
@fantix
fantix merged commit 4083a94 into MagicStack:master Aug 16, 2024
fantix added a commit that referenced this pull request Oct 14, 2024
@fantix
uvloop 0.21.0
40e8a34
Changes
=======

* Add cleanup_socket param on create_unix_server() (#623)
  (by @fantix in d6114d2)

Fixes
=====

* Use cythonized SO_REUSEPORT rather than the unwrapped native one. (#609)
  (by @ptribble in 4083a94 for #550)

* UDP errors should result in protocol.error_received (#601)
  (by @jensbjorgensen in 3c3bbef)

* Updates for Cython3 (#587)
  (by @alan-brooks in 3fba9fa for #587)

* Test with Python 3.13 (#610)
  (by @edgarrmondragon in fb5a139)
@fantix fantix mentioned this pull request Oct 14, 2024
uvloop 0.21.0 #633
Merged
@jakirkham jakirkham mentioned this pull request Oct 15, 2024
uvloop v0.21.0 conda-forge/uvloop-feedstock#47
Merged
3 tasks
@Aryanag2 Aryanag2 mentioned this pull request Feb 11, 2026
LiteLLM Proxy fails to start on Python 3.14 due to uvloop incompatibility BerriAI/litellm#20933
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@fantix fantix fantix approved these changes
+1 more reviewer
@mtelka mtelka mtelka left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

uvloop strictly needs SO_REUSEPORT

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@ptribble @fantix @mtelka
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.