Skip to content

docs: require notify_closing before closing descriptors - #3536

Open
sricharanreddycheruku wants to merge 1 commit into
python-trio:mainfrom
sricharanreddycheruku:batch7-notify-closing-order
Open

sricharanreddycheruku wants to merge 1 commit into
python-trio:mainfrom
sricharanreddycheruku:batch7-notify-closing-order

Conversation

@sricharanreddycheruku

Copy link
Copy Markdown

Problem

The notify_closing documentation says the close steps can be reordered whenever there are no checkpoints. Closing the underlying descriptor before notification is unsafe: on Linux, if the descriptor was duplicated, its epoll registration can survive the close and cannot be removed using the closed descriptor.

Change

Require notification before the actual close, retain the no-checkpoint requirement, and clarify that marking the object closed and notifying waiters may be reordered. Update the shared low-level reference, all three backend docstrings and their generated exports. Add a documentation newsfragment.

Addresses the ordering documentation described in #3520. Its remaining platform implementation issues are outside this documentation change.

Verification

  • Linux epoll reproduction: close-before-unregister raises EBADF and leaves an event registered while a duplicated socket remains open; unregister-before-close leaves no stale event.
  • python src/trio/_tools/gen_exports.py succeeds.
  • sphinx-build -W --keep-going -b html docs/source ... succeeds without warnings.
  • Sphinx lint, Black, Ruff and git diff --check pass for the changed files.
  • AST comparison verifies all six changed Python files differ only in docstrings. Runtime tests were not rerun for this documentation change.

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00000%. Comparing base (bcc9cee) to head (311d6ff).

Additional details and impacted files
@@               Coverage Diff               @@
##                 main        #3536   +/-   ##
===============================================
  Coverage   100.00000%   100.00000%           
===============================================
  Files             128          128           
  Lines           19474        19474           
  Branches         1323         1323           
===============================================
  Hits            19474        19474           
Files with missing lines Coverage Δ
src/trio/_core/_io_epoll.py 100.00000% <ø> (ø)
src/trio/_core/_io_kqueue.py 100.00000% <ø> (ø)
src/trio/_core/_io_windows.py 100.00000% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant