Repository navigation
Test writer backpressure and fix drain cancellation and shutdown - #112
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Native writers had two drain lifecycle gaps: cancelled waits were retained for as long as a peer kept writing paused, and drain() on a closing transport returned success without letting connection_lost run. Retried timeouts could accumulate waiter objects; a write/drain loop could miss shutdown.
This separate test-first PR is based on master 3ff820a and is independent of the reader-usecase PR #111.
Tests use real loopback TCP, events, bounded waits and explicit task/socket cleanup. A raw peer controls consumption; deterministic protocol pause callbacks test retention without kernel timing assumptions. Weak references detect retained cancelled Futures while the peer is still paused. Loop exceptions and leaked tasks fail the tests. Optional uvloop cases skip where unavailable; rsloop cases assert the native writer is used.
Validation actually executed locally on Linux:
CI exposed an overstrict assertion in the new TCP test on Windows Proactor: other drains can legitimately finish while one cancellation is being delivered, because the kernel may accept the queued bytes before the peer application reads. The TCP test now checks that other drains are not cancelled and still deliver every byte; a separate explicitly paused protocol test enforces that cancellation does not wake neighbouring waiters. The test also uses asyncio.TimeoutError for Python 3.10 compatibility. After these test fixes, local release: 30 passed; free-threaded writer matrix: 20 passed, 10 skipped.
Local full suites are not claimed green. Final-head CI (
25f3d3e) completed successfully: Tests run 38046594215 and MkDocs run 38046594204. The full Linux/macOS/Windows Python matrix, including free-threaded builds, passed, alongside default/all-feature Rust, Clippy, Miri, profiling/hotpath, tooling, AnyIO and Redis/hiredis. Windows/macOS validation was performed by GitHub Actions, not locally. No final CI failures remain. No throughput improvement is claimed.