fix: preserve caller-supplied timeout across all retry attempts in request_with_retry#11386
Open
devteamaegis wants to merge 1 commit into
Open
fix: preserve caller-supplied timeout across all retry attempts in request_with_retry#11386devteamaegis wants to merge 1 commit into
devteamaegis wants to merge 1 commit into
Conversation
…quest_with_retry
`timeout` was popped from `kwargs` *inside* the `@retry`-decorated `run()`
closure. On the first attempt `kwargs.pop("timeout", 10)` consumed the key
and used the caller's value; on all subsequent retries the key was gone, so
the pop silently fell back to the hardcoded 10-second default — completely
ignoring whatever the caller had passed.
The fix moves both `kwargs.pop("timeout", 10)` calls (sync and async
variants) to just before the `@retry` decoration so they execute once and
the closed-over `timeout` variable is reused on every attempt.
Adds two regression tests that verify the custom timeout is forwarded on
every attempt, including retries triggered by a transient `RequestError`.
|
Someone is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
devteamaegis seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Member
|
@devteamaegis Thank you for opening this PR. Could you please agree to our CLA? #11386 (comment) |
7 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
request_with_retryandasync_request_with_retryaccept atimeoutkwarg, but that timeout was silently ignored on every retry after the first.Root cause
timeoutwas popped fromkwargsinside the@retry-decoratedrun()closure:kwargs.popmutates the dict in-place. On the first attempt the caller's value is consumed. On every subsequent retry the key is gone, sokwargs.pop("timeout", 10)returns the hardcoded default (10) regardless of what the caller passed.Fix
Move the pop to before the
@retrydecoration — once, not once-per-attempt — so the closed-overtimeoutvariable holds the right value for every attempt:The same fix is applied to
async_request_with_retry.Tests
Added
test_request_with_retry_preserves_timeout_on_retryandtest_async_request_with_retry_preserves_timeout_on_retry. Each test makes the first attempt fail with aRequestErrorso a retry is triggered, then asserts that both calls tohttpx.Client.request/httpx.AsyncClient.requestreceived the caller-suppliedtimeout=42, not the default10.