Open
Description
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
- Create read session with using BigQueryReadAsyncClient
- 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