Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.
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

Closed

Description

@asthamohta
No description provided.

Activity

  1. added
    api: spannerIssues related to the googleapis/python-spanner API.
    samplesIssues that are directly related to samples.
    on Apr 10, 2023
  2. added
    priority: p3Desirable enhancement or fix. May not be included in next release.
    and removed
    api: spannerIssues related to the googleapis/python-spanner API.
    samplesIssues that are directly related to samples.
    on Apr 10, 2023
  3. added
    api: spannerIssues related to the googleapis/python-spanner API.
    samplesIssues that are directly related to samples.
    on Apr 10, 2023
  4. CaliWee commented on Apr 13, 2023

    @CaliWee

    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 - Screen Shot 2023-04-13 at 11 30 22 AM

    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.

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

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/python-spanner API.priority: p3Desirable enhancement or fix. May not be included in next release.samplesIssues that are directly related to samples.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions