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 — Preserve file descriptor blocking mode in add_reader and add_writer by HyunsikParker · Pull Request #761 · MagicStack/uvloop

Conversation

@HyunsikParker

@HyunsikParker HyunsikParker commented Aug 31, 2026

Copy link
Copy Markdown

Fixes #712.

libuv's uv_poll_init() switches the supplied file descriptor to nonblocking mode. uvloop left that change in place after add_reader() or add_writer(), while the asyncio selector loop preserves the original mode.

This records the mode before initializing the poll handle and restores it once initialization finishes. If restoring it fails, the initialized handle is closed before the error is raised.

The regression test covers reader and writer registration and checks the descriptor both while registered and after removal. The same test runs against uvloop and the asyncio reference loop.

Tests:

  • .venv/bin/python -m unittest -v tests.test_sockets (35 passed, 1 skipped)
  • With test_fs_event_rename excluded, 528 tests passed with PYTHONASYNCIODEBUG=1 and again with PYTHONASYNCIODEBUG=0 (39 skipped in each run)
  • The full suite also exposed the existing intermittent macOS test_fs_event_rename failure. Isolated reruns produced one pass and one CHANGE versus RENAME failure.

Sorry, something went wrong.

Uh oh!

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

All reactions
@HyunsikParker
Preserve file descriptor blocking mode for poll handles
18ff542
@HyunsikParker

HyunsikParker commented Sep 1, 2026

Copy link
Copy Markdown
Author

Two Python 3.10 jobs failed. Neither failure is in the new regression test or the modified poll-handle path:

  • Ubuntu: test_process_delayed_stdio__not_paused__no_stdin missed the final stdout and connection-lost stages, then reported live process handles.
  • macOS: test_call_later_rounding measured 50 ms where the test expects at least 69 ms. Fix timers firing up to 1ms early #755 tracks the early-timer behavior.

The other 14 platform and Python-version jobs passed. I ran both failing tests together 10 times locally, and all 10 runs passed. I do not have permission to rerun upstream Actions jobs. Could a maintainer rerun the two failed jobs?

All reactions

Sorry, something went wrong.

Uh oh!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

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.

inconsistent file descriptor blocking state when running in asyncio vs uvloop

Uh oh!

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

1 participant

@HyunsikParker
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.