FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: exclude function target from retry deadline exceeded exception message by sushicw · Pull Request #318 · googleapis/python-api-core · GitHub

This repository was archived by the owner on Feb 23, 2026. It is now read-only.
/ python-api-core Public archive
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (4) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 2 additions & 2 deletions google/api_core/retry.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ def retry_target(target, predicate, sleep_generator, deadline, on_error=None):
if deadline_datetime is not None:
if deadline_datetime <= now:
raise exceptions.RetryError(
"Deadline of {:.1f}s exceeded while calling {}".format(
deadline, target
"Deadline of {:.1f}s exceeded while calling target function".format(
deadline
),
last_exc,
) from last_exc
Expand Down
4 changes: 2 additions & 2 deletions google/api_core/retry_async.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ async def retry_target(target, predicate, sleep_generator, deadline, on_error=No
# Chains the raising RetryError with the root cause error,
# which helps observability and debugability.
raise exceptions.RetryError(
"Deadline of {:.1f}s exceeded while calling {}".format(
deadline, target
"Deadline of {:.1f}s exceeded while calling target function".format(
deadline
),
last_exc,
) from last_exc
Expand Down
4 changes: 4 additions & 0 deletions tests/asyncio/test_retry_async.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ async def test_retry_target_deadline_exceeded(utcnow, sleep):
assert exc_info.match("last exception: meep")
assert target.call_count == 2

# Ensure the exception message does not include the target fn:
# it may be a partial with user data embedded
assert str(target) not in exc_info.exconly()


@pytest.mark.asyncio
async def test_retry_target_bad_sleep_generator():
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_retry.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ def test_retry_target_deadline_exceeded(utcnow, sleep):
assert exc_info.match("last exception: meep")
assert target.call_count == 2

# Ensure the exception message does not include the target fn:
# it may be a partial with user data embedded
assert str(target) not in exc_info.exconly()


def test_retry_target_bad_sleep_generator():
with pytest.raises(ValueError, match="Sleep generator"):
Expand Down

Back | FazBrowse Home | New Git URL