feat(clients): add opt-in retry with backoff for transient failures - #1668
Closed
tharunsridhar wants to merge 1 commit into
Closed
tharunsridhar wants to merge 1 commit into
tharunsridhar wants to merge 1 commit into
Conversation
Add retries and retry_backoff constructor params to the Python client. Off by default (retries=0), so existing behavior is unchanged. When enabled, read methods (search, recall, health, get_document) retry on transport errors and HTTP 429/502/503/504, using the Retry-After header when the server sends one and exponential backoff otherwise. Other 4xx responses are never retried. write() and submit_interview() are excluded by default to avoid duplicating a write whose result is unknown. Closes #551 Signed-off-by: Tharun Sridhar <tharunsridhar@gmail.com>
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.
Closes #551
What
Adds opt-in retry-with-backoff to the Python client for transient failures (429/502/503/504), off by default (
retries=0).Why
A single transient error currently fails the whole call; every consumer was hand-rolling the same retry loop.
Design
retriesandretry_backoffconstructor params, default preserves current behavior.Retry-Afterwhen present, otherwise exponential backoff (retry_backoff * 2**attempt).search,recall,health,get_document);write()andsubmit_interview()are excluded to avoid duplicate-write risk on retry.Testing
Added 18 unit tests covering: default-off behavior is unchanged, retry and backoff timing per read method, all four retryable status codes, that other 4xx are never retried,
Retry-Afteroverriding backoff, and that write operations are never retried even whenretriesis configured.ruff check,ruff format --check, andmypyall pass on the changed file; full client suite is green (183 passed, 7 pre-existing Windows-only failures in unrelated interviewer-CLI tests, unaffected by this change).