Skip to content

Wake tasks reparked into broken parking lots - #3534

Open
harbinresearcher wants to merge 2 commits into
python-trio:mainfrom
harbinresearcher:codex/fix-repark-broken-lot
Open

harbinresearcher wants to merge 2 commits into
python-trio:mainfrom
harbinresearcher:codex/fix-repark-broken-lot

Conversation

@harbinresearcher

Copy link
Copy Markdown

Problem

ParkingLot.repark() currently inserts tasks into an already broken destination. These tasks remain blocked instead of raising BrokenResourceError, unlike tasks that call park() on that destination directly. Calling break_lot() again does not wake them, because it returns early for an already broken lot.

Solution

Reschedule the selected tasks with BrokenResourceError when the destination is broken. Do not enqueue them in the destination. Keep FIFO/count selection and the healthy-destination path unchanged.

The regression tests use real Trio tasks and cover zero, partial, oversized and infinite counts, plus repark_all(). They also verify that unselected source waiters can still be unparked normally.

Testing

  • Pristine parking-lot suite: 11 passed.
  • New regression before the fix: 5 failed, 1 passed (zero-count no-op).
  • Parking-lot and synchronization suites after the fix: 55 passed.
  • Parking-lot implementation and test module: 100% measured statement/branch coverage in that focused run.
  • Windows Python 3.14.6 expanded suite, excluding baseline-reproduced environment failures: 810 passed, 83 skipped, 8 deselected, 3 xfailed.
  • Ruff, Black, focused mypy and git diff --check passed.
  • Repository pre-commit checks passed for the changed source/test files (after normalizing mixed line endings).
Unfiltered-suite limits on this machine

The unfiltered patched suite had 810 passed, 85 skipped, 3 xfailed and 6 failed. All six failures also occurred on pristine bcc9ceeb8b22134515d3d4f66a99c14783bd5e6f: five tests compare Chinese-localized Windows errors to English messages, and the REPL keyboard-interrupt test decodes non-UTF-8 subprocess output as UTF-8.

Excluded functions (eight cases, including platform skips): test_wait_on_invalid_object, test_open_tcp_listeners_rebind, test_ki_in_repl, test_WaitForMultipleObjects_sync, test_WaitForSingleObject, test_pipe_error_on_close.

The pristine unfiltered run had 803 passed, 85 skipped, 3 xfailed and 7 failed, including an additional intermittent socket-writability failure. An initial patched run also had a socket-writability failure; subsequent patched runs passed those tests. No unrelated IO tests or implementation were changed.

AI assistance: OpenAI Codex. The exact model version is not available in this environment.

@codecov

codecov Bot commented Oct 6, 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 (2530d16).

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

@TeamSpen210

Copy link
Copy Markdown
Contributor

Not sure this makes much sense, repark() should just immediately raise and do nothing instead.

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.

2 participants