Repository navigation
Conversation
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.
fornwall
force-pushed
the
fix-dbapi-read-partition-cancel
branch
from
November 12, 2026 08:07
892d6d1 to
0c7cd27
Compare
… 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> Assisted-by: OpenAI Codex
…results Assert that the row iterator created by adbc_read_partition() cancels the connection, which the SIGINT handler uses during fetches. Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net> Assisted-by: OpenAI Codex
fornwall
force-pushed
the
fix-dbapi-read-partition-cancel
branch
from
November 13, 2026 02:57
0c7cd27 to
b5001be
Compare
Assisted-by: OpenAI Codex Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
lidavidm
reviewed
Nov 17, 2026
Comment on lines
+43
to
+46
| partitions, _ = cur.adbc_execute_partitions("SELECT 1") | ||
| cur.adbc_read_partition(partitions[0]) | ||
| assert cur._results._cancel == test_dbapi.adbc_connection.cancel | ||
| assert cur.fetchone() == (5,) |
Member
There was a problem hiding this comment.
I'd rather not assert on internals, but if we have to do it, let's make it a new test.
Member
There was a problem hiding this comment.
I'd also want to ensure that executing another operation resets _cancel.
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.

Cancelling the statement does not interrupt connection-owned partition reads or their result streams.
Assisted-by: OpenAI Codex