Skip to content

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 #793

@fohria

Description

@fohria

Environment details

  • OS type and version: Win10/WSL2 with Ubuntu 22.04
  • Python version: 3.10.13
  • pip version: 23.3.1
  • google-cloud-firestore version: 2.13.1

Steps to reproduce

  1. Retrieve a collection with the firestore AsyncClient
  2. Get warning that synchronous client is used instead of asynchrounous one

Code example

client = firestore.AsyncClient(project=project, credentials=cred)
collection = client.async_client.collection(name)

Stack trace

File "/home/user/mambaforge/envs/env-name/lib/python3.10/site-packages/google/cloud/firestore_v1/async_document.py", line 367, in get
    response_iter = await self._client._firestore_api.batch_get_documents(
  File "/home/user/mambaforge/envs/env-name/lib/python3.10/site-packages/google/cloud/firestore_v1/services/firestore/async_client.py", line 758, in batch_get_documents
    response = rpc(
  File "/home/user/mambaforge/envs/env-name/lib/python3.10/site-packages/google/api_core/gapic_v1/method.py", line 131, in __call__
    return wrapped_func(*args, **kwargs)
  File "/home/user/mambaforge/envs/env-name/lib/python3.10/site-packages/google/api_core/retry.py", line 372, in retry_wrapped_func
    return retry_target(
  File "/home/user/mambaforge/envs/env-name/lib/python3.10/site-packages/google/api_core/retry.py", line 209, in retry_target
    warnings.warn(_ASYNC_RETRY_WARNING)
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.

Potential cause/solution

In the file google/cloud/firestore_v1/services/firestore/async_client.py the following import is made:

from google.api_core import retry as retries

I believe it should be:

from google.api_core import retry_async as retries

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: firestoreIssues related to the googleapis/python-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions