Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit f5eb290

Browse files
committed
fix: add warning to retry target to avoid incorrect use
1 parent 405272c commit f5eb290

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

google/api_core/operations_v1/operations_async_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
from google.api_core import exceptions as core_exceptions
2828
from google.api_core import gapic_v1, page_iterator_async
29-
from google.api_core import retry as retries
29+
from google.api_core import retry_async as retries
3030
from google.api_core import timeout as timeouts
3131
from google.longrunning import operations_pb2
3232
from grpc import Compression
@@ -48,7 +48,7 @@ def __init__(self, channel, client_config=None):
4848
# Create the gRPC client stub with gRPC AsyncIO channel.
4949
self.operations_stub = operations_pb2.OperationsStub(channel)
5050

51-
default_retry = retries.Retry(
51+
default_retry = retries.AsyncRetry(
5252
initial=0.1, # seconds
5353
maximum=60.0, # seconds
5454
multiplier=1.3,

google/api_core/retry.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def check_if_exists():
6262
import random
6363
import sys
6464
import time
65+
import inspect
6566
from typing import Any, Callable, TypeVar, TYPE_CHECKING
6667

6768
import requests.exceptions
@@ -201,7 +202,10 @@ def retry_target(
201202

202203
for sleep in sleep_generator:
203204
try:
204-
return target()
205+
result = target()
206+
if inspect.isawaitable(result):
207+
raise exceptions.GoogleAPIError("Warning: Use google.api_core.retry_async.AsyncRetry for async calls!")
208+
return result
205209

206210
# pylint: disable=broad-except
207211
# This function explicitly must deal with broad exceptions.

0 commit comments

Comments
 (0)