Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit34ebdcc

Browse files
sushicwparthea
andauthored
fix: exclude function target from retry deadline exceeded exception message (#318)
* Exclude function target from retry deadline exceeded exception message* apply similar patch in retry_async.pyCo-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parentcc46aa6 commit34ebdcc

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

‎google/api_core/retry.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ def retry_target(target, predicate, sleep_generator, deadline, on_error=None):
203203
ifdeadline_datetimeisnotNone:
204204
ifdeadline_datetime<=now:
205205
raiseexceptions.RetryError(
206-
"Deadline of {:.1f}s exceeded while calling{}".format(
207-
deadline,target
206+
"Deadline of {:.1f}s exceeded while callingtarget function".format(
207+
deadline
208208
),
209209
last_exc,
210210
)fromlast_exc

‎google/api_core/retry_async.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ async def retry_target(target, predicate, sleep_generator, deadline, on_error=No
132132
# Chains the raising RetryError with the root cause error,
133133
# which helps observability and debugability.
134134
raiseexceptions.RetryError(
135-
"Deadline of {:.1f}s exceeded while calling{}".format(
136-
deadline,target
135+
"Deadline of {:.1f}s exceeded while callingtarget function".format(
136+
deadline
137137
),
138138
last_exc,
139139
)fromlast_exc

‎tests/asyncio/test_retry_async.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ async def test_retry_target_deadline_exceeded(utcnow, sleep):
120120
assertexc_info.match("last exception: meep")
121121
asserttarget.call_count==2
122122

123+
# Ensure the exception message does not include the target fn:
124+
# it may be a partial with user data embedded
125+
assertstr(target)notinexc_info.exconly()
126+
123127

124128
@pytest.mark.asyncio
125129
asyncdeftest_retry_target_bad_sleep_generator():

‎tests/unit/test_retry.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ def test_retry_target_deadline_exceeded(utcnow, sleep):
152152
assertexc_info.match("last exception: meep")
153153
asserttarget.call_count==2
154154

155+
# Ensure the exception message does not include the target fn:
156+
# it may be a partial with user data embedded
157+
assertstr(target)notinexc_info.exconly()
158+
155159

156160
deftest_retry_target_bad_sleep_generator():
157161
withpytest.raises(ValueError,match="Sleep generator"):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp