fix(client): check for should retry header (#606)

Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
This commit is contained in:
Aaron Pham
2023-11-10 17:50:12 -05:00
committed by GitHub
parent c41828f68f
commit b65b1bbc52

View File

@@ -313,10 +313,11 @@ class BaseClient(t.Generic[InnerClient, StreamType]):
def _should_retry(self, response: httpx.Response) -> bool:
should_retry_header = response.headers.get('x-should-retry')
if should_retry_header.lower() == 'true':
return True
if should_retry_header.lower() == 'false':
return False
if should_retry_header:
if should_retry_header.lower() == 'true':
return True
if should_retry_header.lower() == 'false':
return False
if response.status_code in {408, 409, 429}:
return True
if response.status_code >= 500: