feat(sqlalchemy-spanner): wire timeout execution option through to DBAPI Connection.timeout
Maintainer thường phản hồi trong vòng 1 ngày
@sakthivelmanii đang làm issue này rồi.
Từ ngày 24/9/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
Hướng nghiên cứu
Bắt đầu trong google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py tại SpannerExecutionContext.pre_exec() và reset_connection(), đồng thời so sánh cách xử lý request_priority hiện có. Xác nhận điều kiện tiên quyết là thuộc tính timeout của DBAPI Connection, sau đó kiểm tra rằng các tùy chọn thực thi được truyền đến connection và được đặt lại thành None khi các pooled connection được trả về.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The SQLAlchemy Spanner dialect does not handle timeout in execution_options. Users cannot set a per-statement gRPC deadline through SQLAlchemy, causing all queries to use the gRPC default timeout of 3600 seconds.
Background
The Spanner SQLAlchemy dialect (SpannerExecutionContext.pre_exec()) reads execution options and forwards them to the DBAPI connection. Currently handled options: read_only, staleness, request_priority, transaction_tag, request_tag. The timeout option is not handled.
The dialect's reset_connection() method resets read_only, staleness, request_priority, transaction_tag, and request_tag on the DBAPI connection when returning connections to the pool. timeout is not reset.
Timeline
| Date | Commit | Event |
|---|---|---|
| Apr 2020 | Initial commit | Dialect created — pre_exec() handles read_only and staleness |
| Oct 2021 | d976fda (PR googleapis/python-spanner#269) |
request_priority added to pre_exec() |
| Jan 2023 | 5bd5076 (PR googleapis/python-spanner#494) |
transaction_tag and request_tag added to pre_exec() |
| Jun 2023 | 66c32a4 (PR googleapis/python-spanner#503) |
ignore_transaction_warnings added to pre_exec() |
| None | N/A | timeout was never added to pre_exec() or reset_connection() |
Each new execution option was added incrementally. timeout was not included in any of these additions.
Proposed Change
Add timeout handling to SpannerExecutionContext.pre_exec() following the existing pattern for request_priority:
- Read
self.execution_options.get("timeout") - Set
self._dbapi_connection.connection.timeout = timeout - Reset
timeouttoNoneinreset_connection()
Files changed
google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py— Addtimeouthandling topre_exec()andreset_connection()
Usage
from sqlalchemy import create_engine
engine = create_engine("spanner:///...")
# Per-connection timeout
with engine.connect().execution_options(timeout=60) as conn:
conn.execute(text("SELECT * FROM my_table"))
# Engine-level default timeout
engine = create_engine("spanner:///...", execution_options={"timeout": 60})
Prerequisites
This change depends on the DBAPI Connection supporting a timeout property: googleapis/google-cloud-python#16492
Related
- DBAPI issue: googleapis/google-cloud-python#16492
_SnapshotBase.execute_sql()has acceptedtimeout=since November 2018 (PR #6536 in the original monorepo)- This code was previously in
googleapis/python-spanner-sqlalchemy(now archived) and moved togoogleapis/google-cloud-python/packages/sqlalchemy-spanner
- Ngôn ngữ chính
- Python
- Star
- 5.4k
- Fork
- 1.8k
- Merge trung bình
- 2 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 142
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/google-cloud-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
googleapis/google-cloud-python#18532 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 92/100
googleapis/google-cloud-python#18467 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
auth priority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
googleapis/google-cloud-python#18428 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
googleapis/google-cloud-python#18375 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ci: enable --strict flag in presubmit twine_checkCó thể đã có người làm @ohmayr đã nhận 1 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
googleapis/google-cloud-python#18339 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleapis/google-cloud-python
Issue tương tự
-
New InternshipĐang mởnew_internship
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
-
[BUG] Reports tab: "Unban" button tooltip shows raw `{{ip}}` placeholder instead of the IP addressĐang mởbug javascript ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
bunkerity/bunkerweb#4001 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
PedestrianDynamics/pyFDS-Evac#476 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
google/differential-privacy#516 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
adobe-fonts/source-serif#153 ·