Repository navigation
Conversation
…provider's error Re-raise non-retryable APIStatusError immediately, retry 5xx and network errors max_retry times after the first attempt, and let the final error be the provider's status (or an APIConnectionError chained to the network error) instead of a generic "after all retries". Same shape as livekit#7314 for Anam.
This branch has not been deployed
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.
AvatarSession._send_request_with_retryretries every failure, including 4xx responses that can never succeed. With a wrong API secret a cloud avatar takes about 4 seconds to fail, logs three tracebacks, and ends with a retryableAPIConnectionError("Failed to start Bithuman Avatar Session after all retries")that has lost the 401 and the response body.The loop catches
Exception, which includes theAPIStatusErrorit raises itself for a non-2xx response, logs each one withlogger.exception, and always finishes with a generic, unchainedAPIConnectionError. It also runsrange(max_retry), one attempt fewer than the other avatar plugins.This is the same change #7314 made for Anam (and #7494, #7496 for Tavus and Bey). A non-retryable
APIStatusErroris re-raised immediately. 5xx and network errors are retriedmax_retrytimes after the first attempt with a warning (status code only, no payload), and the final error is the provider'sAPIStatusError, or anAPIConnectionErrorchained to the network error. It covers both the default and custom-endpoint requests since they share the helper;aiohttp.FormDatais reusable across attempts on the pinned aiohttp, so retrying the custom-endpoint upload is safe. It doesn't overlap #7492, which touches other parts ofavatar.py.Against a local server with default connect options, on
main: a 401 takes 4.00s, three tracebacks, genericAPIConnectionError; a persistent 503 is the same. With this change a 401 raisesAPIStatusError(status_code=401)on the first attempt with no traceback, 503, 503, 200 still succeeds, and a persistent 503 raisesAPIStatusError(status_code=503)after four attempts (6.01s, one more attempt than before, matching Anam). Four tests added in a newtests/test_plugin_bithuman.py; all four fail onmain.Closes #7499.