You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 8, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jun 8, 2026. It is now read-only.
Add sample for passing timeout and retry parameters #927
As a user, it would be really helpful if the documentation were updated wherever possible to help users configure timeouts as the default timeout settings seem to vary between operations and can be limiting.
Activity
CaliWee commentedon Apr 13, 2023
The documentation for configuring request timeouts is not well documented in Python -
https://cloud.google.com/spanner/docs/custom-timeout-and-retry
It seems that setting a timeout for a request is possible, as it is documented in the SpannerClient class - https://cloud.google.com/python/docs/reference/spanner/latest/google.cloud.spanner_v1.services.spanner.SpannerClient
However, most use cases in the documentation use the Client, Instance, and Database class -
https://cloud.google.com/spanner/docs/reference/libraries#use
https://cloud.google.com/python/docs/reference/spanner/latest/google.cloud.spanner_v1.client.Client
And from the Client, an instance and database class are instantiated to conduct operations.
Personally I have been attempting to utilize the transaction method batch_update -
https://cloud.google.com/python/docs/reference/spanner/latest/google.cloud.spanner_v1.transaction.Transaction#google_cloud_spanner_v1_transaction_Transaction_batch_update
The documentation specifies that you may provide request options to this method, but the only option that is configurable is the Priority of the request.
https://cloud.google.com/python/docs/reference/spanner/latest/google.cloud.spanner_v1.types.RequestOptions
In practice this method seems to have a default timeout of ~30s -
In the database.run_in_transaction method documentation there is a kwarg "timeout_secs", but this is the timeout configuration for the retry behavior and not the request itself. Setting this timeout to 540 does not resolve the request timeout issue.
https://cloud.google.com/python/docs/reference/spanner/latest/google.cloud.spanner_v1.database.Database#google_cloud_spanner_v1_database_Database_run_in_transaction
As a user, it would be really helpful if the documentation were updated wherever possible to help users configure timeouts as the default timeout settings seem to vary between operations and can be limiting.