fix: honor custom timeout on every attempt in request_with_retry#11998
Open
eeshsaxena wants to merge 5 commits into
Open
fix: honor custom timeout on every attempt in request_with_retry#11998eeshsaxena wants to merge 5 commits into
eeshsaxena wants to merge 5 commits into
Conversation
The inner retried function popped `timeout` from the shared `kwargs` dict, so after the first attempt it was gone and every retry silently fell back to the default of 10 seconds. Pop `timeout` once, before the retry loop, so it is captured for all attempts. Applies to both `request_with_retry` and `async_request_with_retry`. Adds regression tests asserting the caller's timeout is used on the retry too.
|
@eeshsaxena is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
sjrl
reviewed
Jul 14, 2026
sjrl
reviewed
Jul 14, 2026
sjrl
reviewed
Jul 17, 2026
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.
Related Issues
No linked issue - found while reading the retry helper.
Proposed Changes:
request_with_retryandasync_request_with_retryrespect a customtimeoutonly on the first attempt; every retry silently falls back to the default of 10 seconds.The cause is that
timeoutis popped from the sharedkwargsdict inside the@retry-decorated innerrun():run()is re-invoked on each retry andkwargsis captured by closure, so the first attempt removestimeoutfromkwargsand subsequent attempts get the10default. A caller doingrequest_with_retry(url=..., timeout=30, attempts=3)getstimeout=30on attempt 1 andtimeout=10on the retries.The fix pops
timeoutonce, before the retry loop, so it is captured for every attempt. Applied to both the sync and async functions.How did you test it?
test/utils/test_requests_utils.py(sync and async): the first attempt fails with a retryable error, and the test asserts both the initial attempt and the retry are called with the caller'stimeout, not the default. These fail on the current code ([5, 10]) and pass with the fix ([5, 5]).test_..._custom_timeoutonly asserted the first attempt (assert_called_once_with), which is why this slipped through.httpx.Client.requestto record the per-attempt timeout: current[5, 10, 10]fortimeout=5, attempts=3, fixed[5, 5, 5]. Same for the async path.ruff checkandruff formatclean. Added a release note underreleasenotes/notes/.Notes for the reviewer
No source behavior changes beyond the timeout handling; the only functional change is that retries now use the caller's timeout. An AI assistant helped identify and implement this fix; I reviewed all changes and ran the tests locally.
Checklist