Skip to content

Commit

Permalink
feat(client): retry on 408 Request Timeout (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Sep 14, 2023
1 parent da6ccb1 commit 46386f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ Error codes are as followed:
### Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
Connection errors (for example, due to a network connectivity problem), 409 Conflict, 429 Rate Limit,
and >=500 Internal errors will all be retried by default.
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
429 Rate Limit, and >=500 Internal errors will all be retried by default.

You can use the `max_retries` option to configure or disable this:

Expand Down
4 changes: 4 additions & 0 deletions src/anthropic/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,10 @@ def _should_retry(self, response: httpx.Response) -> bool:
if should_retry_header == "false":
return False

# Retry on request timeouts.
if response.status_code == 408:
return True

# Retry on lock timeouts.
if response.status_code == 409:
return True
Expand Down

0 comments on commit 46386f8

Please sign in to comment.