Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the synchronous google.api_core.retry.Retry with asynchronous calls may lead to unexpected results. Please use google.api_core.retry_async.AsyncRetry instead. #718

Open
dszady-rtb opened this issue Dec 6, 2023 · 0 comments
Labels
api: bigquerystorage Issues related to the googleapis/python-bigquery-storage API.

Comments

@dszady-rtb
Copy link

Environment details

  • OS type and version: macOS Ventura 13.0
  • Python version: 3.11.2
  • pip version: pip 22.3.1
  • google-cloud-bigquery-storage version: 2.23.0

Steps to reproduce

  1. Create read session with using BigQueryReadAsyncClient
  2. Get warning that synchronous retry is used instead of asynchrounous one

Code example

 def create_read_session(
    bq_table_path: str,  # in project.dataset.table format
):
    project_id, dataset_id, table_id = bq_table_path.split(".")

    client = BigQueryReadAsyncClient()

    read_sessions_type = types.ReadSession(
        table=f"projects/{project_id}/datasets/{dataset_id}/tables/{table_id}",
        data_format=types.DataFormat.AVRO,
        read_options=types.ReadSession.TableReadOptions(
            selected_fields=[column.name for column in dataclasses.fields(row_type)],
            row_restriction=row_restriction,
        ),
    )
    create_read_session_request = types.CreateReadSessionRequest(
        parent=f"projects/{project_id}",
        read_session=read_sessions_type,
        max_stream_count=1,
    )

    read_session = await client.create_read_session(request=create_read_session_request)

    return read_session

read_session = create_read_session("project.dataset.table") # Pass real table info here

Stack trace

[07:56:35.336075 UTC] [py.warnings] [WARNING] /Users/dominik/Library/Caches/pypoetry/virtualenvs/jobs-stats-FS2xMDD8-py3.11/lib/python3.11/site-packages/google/api_core/retry.py:209: UserWarning: Using the synchronous google.api_core.retry.Retry with asynchronous calls may lead to unexpected results. Please use google.api_core.retry_async.AsyncRetry instead.
  warnings.warn(_ASYNC_RETRY_WARNING)

Potential cause/solution

In the file google/cloud/bigquery_storage_v1/services/bigquery_read/async_client.py the following import is made:

from google.api_core import retry as retries

and I believe it should be:

from google.api_core import retry_async as retries

This seems like an issue in other async clients too (eg. BigQueryWriteAsyncClient)

Also here was similiar issue in googleapis/python-firestore:
googleapis/python-firestore#793

@product-auto-label product-auto-label bot added the api: bigquerystorage Issues related to the googleapis/python-bigquery-storage API. label Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquerystorage Issues related to the googleapis/python-bigquery-storage API.
Projects
None yet
Development

No branches or pull requests

1 participant