Skip to content

Commit

Permalink
fix: add warning to retry_target to avoid incorrect usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ohmayr committed Oct 26, 2023
1 parent 405272c commit 439605a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion google/api_core/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def check_if_exists():
import random
import sys
import time
import inspect
from typing import Any, Callable, TypeVar, TYPE_CHECKING

import requests.exceptions
Expand Down Expand Up @@ -201,7 +202,10 @@ def retry_target(

for sleep in sleep_generator:
try:
return target()
result = target()
if inspect.isawaitable(result):
raise exceptions.GoogleAPIError("Warning: Use google.api_core.retry_async.AsyncRetry for async calls!")
return result

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

0 comments on commit 439605a

Please sign in to comment.