fix: make Python record batch reader cancellable - #885
Merged
JingsongLi merged 1 commit intoSep 20, 2026
Merged
Conversation
leaves12138
approved these changes
Sep 20, 2026
leaves12138
left a comment
There was a problem hiding this comment.
LGTM. Reviewed the stream mutex, atomic closed state, and stored Notify permit: the close path does not wait for an in-flight next, and the permit covers the gap between the closed check and notification polling.
Validation against this head:
- 77 Rust binding tests passed, including three additional local tests for close-before-read, concurrent next/repeated close, and 200 close/first-poll races with stream-drop assertions.
- Rebuilt the Python extension and ran test_read.py: 82 passed.
- An additional end-to-end Python test held a native S3 request pending against a local HTTP endpoint; close interrupted read_next_batch before the endpoint was released, and repeated close/subsequent EOF behaved correctly.
No blocking correctness or lifecycle issues found in this change.
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.
Summary
Motivation
Parallel PyPaimon reads may close after one reader produces a batch while another reader is still blocked in its first native read. The Python executor cannot finish until that in-flight Rust operation is cancellable. The close path uses an atomic flag and Tokio Notify, so it does not contend on the mutex held by next_record_batch.
Tests