Conversation
… partition Cursor.adbc_read_partition() reads through AdbcConnectionReadPartition and the returned stream belongs to the connection, but the cursor cancelled its statement instead: both from the SIGINT handler around the blocking calls and from Cursor.adbc_cancel(). A driver with no active query on the statement treats that as a no-op, leaving the partition read running. Track the current cancel target on the cursor: the statement after _clear()/execute(), the connection after adbc_read_partition(). Use it for adbc_cancel(), the blocking partition read, and the row iterator that consumes the result stream. Fix the AdbcStatement.cancel docstring, which claimed to cancel the connection. Test against the Flight SQL test server, whose "forever" query blocks ReadPartition until the client cancels the connection. Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Cancellation during subsequent partition-stream fetching remains untested.
Review effort: Balanced
Findings: 1
What changed in this PR
Updates Python DB-API cancellation routing so partition reads cancel through their owning connection.
Changes:
- Tracks the active cancellation target per cursor.
- Uses connection cancellation for partition reads and stream consumption.
- Adds Flight SQL cancellation coverage and corrects statement documentation.
| File | Description |
|---|---|
python/adbc_driver_manager/adbc_driver_manager/dbapi.py |
Routes cancellation to the active statement or connection. |
python/adbc_driver_manager/adbc_driver_manager/_lib.pyx |
Corrects the statement cancellation docstring. |
python/adbc_driver_flightsql/tests/test_errors.py |
Tests cancellation of blocked partition reads. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ) | ||
| self._rowcount = -1 | ||
| self._results = _RowIterator(self._stmt, handle, self._backend) | ||
| self._results = _RowIterator(self._cancel, handle, self._backend) |
This branch has not been deployed
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.

Cursor.adbc_read_partition()reads throughAdbcConnectionReadPartitionand the returned stream belongs to the connection, but the cursor cancelled its statement instead: both from the SIGINT handler around the blocking calls and fromCursor.adbc_cancel(). A driver with no active query on the statement treats that as a no-op, leaving the partition read running.Track the current cancel target on the cursor: the statement after _clear()/execute(), the connection after
adbc_read_partition(). Use it foradbc_cancel(), the blocking partition read, and the row iterator that consumes the result stream. Fix theAdbcStatement.canceldocstring, which claimed to cancel the connection.Test against the Flight SQL test server, whose "forever" query blocks ReadPartition until the client cancels the connection.
AI disclaimer: Created with codex and gpt-6 astra. Iterated on and reviewed by me.