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 — udp errors should result in protocol.error_received, inconsistent with vanilla asyncio by jensbjorgensen · Pull Request #601 · MagicStack/uvloop

Conversation

@jensbjorgensen

@jensbjorgensen jensbjorgensen commented Mar 13, 2024

Copy link
Copy Markdown
Contributor

I observed a condition in production where a temporary network outage caused a UDP sendto to fail. In stock asyncio this would result in a call to error_received on the protocol object, but in uvloop this results in a fatal error that closes the transport. This is a rather nasty thing to happen since with vanilla asyncio when the transient network condition was resolved the transport could again be used, but with uvloop you would have to close the transport and repoen it.. See cpython source here:

https://github.com/python/cpython/blob/main/Lib/asyncio/selector_events.py#L1240

Sorry I don't have a script/fragment to reproduce the error, to do this you'd have to manipulate the networking stack such that the interface was not available after the transport was created. It's possible of course but I don't know of an easy way to do this.

Sorry, something went wrong.

Uh oh!

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

All reactions
fantix
fantix requested changes Aug 15, 2024
View reviewed changes
Comment thread uvloop/handles/udp.pyx Outdated
Comment on lines +257 to +260
if isinstance(exc, OSError):
self._protocol.error_received(exc)
else:
self._fatal_error(exc, True)

@fantix fantix Aug 15, 2024

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.

I think this can be replaced by calling _on_sent() with the converted exception.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread uvloop/handles/udp.pyx Outdated
exc = convert_error(err)
self._fatal_error(exc, True)
if isinstance(exc, OSError):
self._protocol.error_received(exc)

@fantix fantix Aug 15, 2024

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.

This needs to be wrapped with run_in_context...(), see also the _on_sent() below.

Sorry, something went wrong.

Uh oh!

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

All reactions
Jens Jorgensen added 2 commits August 26, 2024 12:51
Jens Jorgensen
udp errors should result in protocol.error_received
29bba19
Jens Jorgensen
fixes per @fantix
dd53a3e
@jensbjorgensen
jensbjorgensen force-pushed the udp_protocol_error_not_fatal branch from e55cebd to dd53a3e Compare August 26, 2024 17:51
fantix
fantix approved these changes Aug 26, 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.

Thanks!

Sorry, something went wrong.

Uh oh!

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

All reactions
@fantix
fantix merged commit 3c3bbef into MagicStack:master Aug 26, 2024
@jensbjorgensen
jensbjorgensen deleted the udp_protocol_error_not_fatal branch September 2, 2024 17:17
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
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

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.

Uh oh!

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

2 participants

@jensbjorgensen @fantix
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.