fix: add SQL query timeout and cancellation controls

Add per-query SQL deadlines, read timeouts, and drop cancellation controls for Rust and Python.
This commit is contained in:
Jack Ye
2026-11-21 14:35:04 -08:00
committed by GitHub
parent 7970d3075c
commit e3e55844bc
21 changed files with 834 additions and 52 deletions
+22 -1
View File
@@ -306,7 +306,8 @@ call or return a polling continuation that the SDK follows automatically.
This behavior is the same with and without parameters. Open the reader directly;
a directly streamed query needs its reader to make progress. Dropping an unread
handle or its reader stops direct streaming. Deferred execution continues until
explicitly cancelled.
explicitly cancelled by default; use `cancel_on_drop=True` to attempt cancellation
when its unread handle or reader is dropped.
For example:
@@ -360,6 +361,26 @@ reader = db.execute_query(
# await query.cancel()
```
Set `timeout` to bound submission and result consumption together, including
any time before opening a reader. Set `read_timeout` to limit each server read.
Both accept `datetime.timedelta` and apply to one execution. An expired timeout
or failed result read stops reading and attempts to cancel Flight execution.
Cancellation on drop requires the submitting runtime to remain alive. Durable
server-side jobs require explicit `db.cancel_job(query.job_id)`.
```python
from datetime import timedelta
query = db.execute_query_async(
"SELECT * FROM events",
timeout=timedelta(seconds=30),
read_timeout=timedelta(seconds=5),
cancel_on_drop=True,
)
# To stop this execution explicitly:
query.cancel()
```
## Namespaces (Synchronous)
A namespace-backed connection resolves tables through a