Skip to content

feat(sqlalchemy-spanner): wire timeout execution option through to DBAPI Connection.timeout - #18485

Open
sakthivelmanii wants to merge 1 commit into
mainfrom
feat/sqlalchemy-spanner-timeout
Open

sakthivelmanii wants to merge 1 commit into
mainfrom
feat/sqlalchemy-spanner-timeout

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor
  • Reset connection timeout to None on pool checkin in reset_connection.
  • Support timeout execution option in SpannerExecutionContext.pre_exec.
  • Restore baseline connection timeout in post_exec and handle_dbapi_exception to prevent statement-level timeout leakage across queries on the same connection.
  • Add unit tests for execution options timeout lifecycle.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@sakthivelmanii
sakthivelmanii requested a review from a team as a code owner September 28, 2026 12:07

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for statement-level timeouts in the SpannerExecutionContext by saving the original connection timeout before execution, applying the execution option's timeout, and restoring the original timeout in post_exec and handle_dbapi_exception. It also resets the timeout to None when resetting the connection. The review feedback suggests wrapping the timeout restoration logic in a try...except block to prevent secondary exceptions (e.g., on a broken connection) from masking the primary database exception.

@sakthivelmanii
sakthivelmanii force-pushed the feat/sqlalchemy-spanner-timeout branch 2 times, most recently from dc7b725 to a41432e Compare September 28, 2026 12:46
…API Connection.timeout

- Reset connection timeout to None on pool checkin in reset_connection.
- Support timeout execution option in SpannerExecutionContext.pre_exec.
- Use scoped save-and-restore in SpannerExecutionContext to restore connection timeout in post_exec and handle_dbapi_exception.
- Add unit tests covering timeout lifecycle and exception restoration.
@sakthivelmanii
sakthivelmanii force-pushed the feat/sqlalchemy-spanner-timeout branch from a41432e to ceac66c Compare September 28, 2026 14:20

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant