-
Notifications
You must be signed in to change notification settings - Fork 21
[ISSUE-153] Add blocking poll into python bindings #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a poll() method to the Python LogScanner bindings, enabling incremental, timeout-based record reading with a configurable timeout parameter.
Changes:
- Added
LogScanner.poll(timeout_ms)method with input validation and timeout handling - Implemented
create_empty_table()helper method to return properly-schemed empty tables on timeout - Added example usage demonstrating the new poll-based consumption pattern
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| bindings/python/src/table.rs | Implements the new poll() method with validation, error handling, and empty table creation helper |
| bindings/python/example/example.py | Adds example demonstrating usage of the new poll() method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// - Returns an empty table (with correct schema) if no records are available | ||
| /// - When timeout expires, returns an empty table (NOT an error) | ||
| fn poll(&self, py: Python, timeout_ms: i64) -> PyResult<Py<PyAny>> { | ||
| use std::time::Duration; |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use std::time::Duration import is redundant. The Duration type is already used in the to_arrow() method at line 253 without a local import, suggesting it's available in scope. Consider removing this redundant import for consistency.
| # TODO: support to_duckdb() | ||
|
|
||
| # Test the new poll() method for incremental reading | ||
| print("\n--- Testing poll() method ---") |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example calls subscribe() again before polling, but there's no explanation of why this is necessary or whether it resets the scanner state. Consider adding a comment explaining this step, similar to line 163 which says '# Reset subscription'.
| print("\n--- Testing poll() method ---") | |
| print("\n--- Testing poll() method ---") | |
| # Reset subscription before polling to ensure we start from a known position |
luoyuxia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fresh-borzoni Thanks for the pr. Only one question. PTAL
|
|
||
| let timeout = Duration::from_millis(timeout_ms as u64); | ||
| let scan_records = py | ||
| .detach(|| TOKIO_RUNTIME.block_on(async { self.inner.poll(timeout).await })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, I'm thinking can we use scanner#poll_batches directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, thank you!
Purpose
Linked issue: close #153
Add a
poll()method to Python LogScanner for incremental, timeout-based record reading.Brief change log
LogScanner.poll(timeout_ms)method to Python bindingsAPI and Format
LogScanner.poll(timeout_ms: int) -> pyarrow.Table