_sleep_for_retry() — anthropic-sdk-python Function Reference
Architecture documentation for the _sleep_for_retry() function in _base_client.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 45cb7b8c_88f3_ad66_a029_ae39dee52385["_sleep_for_retry()"] 3224f719_8046_78c8_59e1_47301a46ddd4["AsyncAPIClient"] 45cb7b8c_88f3_ad66_a029_ae39dee52385 -->|defined in| 3224f719_8046_78c8_59e1_47301a46ddd4 e28246be_5825_36c7_9258_c1395a05766e["_sleep_for_retry()"] e28246be_5825_36c7_9258_c1395a05766e -->|calls| 45cb7b8c_88f3_ad66_a029_ae39dee52385 c21c2971_d83f_0afc_9811_0642b34cfcd3["request()"] c21c2971_d83f_0afc_9811_0642b34cfcd3 -->|calls| 45cb7b8c_88f3_ad66_a029_ae39dee52385 f6d7d851_1218_0312_84fe_55254f0ab693["_calculate_retry_timeout()"] 45cb7b8c_88f3_ad66_a029_ae39dee52385 -->|calls| f6d7d851_1218_0312_84fe_55254f0ab693 e28246be_5825_36c7_9258_c1395a05766e["_sleep_for_retry()"] 45cb7b8c_88f3_ad66_a029_ae39dee52385 -->|calls| e28246be_5825_36c7_9258_c1395a05766e style 45cb7b8c_88f3_ad66_a029_ae39dee52385 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/_base_client.py lines 1791–1803
async def _sleep_for_retry(
self, *, retries_taken: int, max_retries: int, options: FinalRequestOptions, response: httpx.Response | None
) -> None:
remaining_retries = max_retries - retries_taken
if remaining_retries == 1:
log.debug("1 retry left")
else:
log.debug("%i retries left", remaining_retries)
timeout = self._calculate_retry_timeout(remaining_retries, options, response.headers if response else None)
log.info("Retrying request to %s in %f seconds", options.url, timeout)
await anyio.sleep(timeout)
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does _sleep_for_retry() do?
_sleep_for_retry() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_base_client.py.
Where is _sleep_for_retry() defined?
_sleep_for_retry() is defined in src/anthropic/_base_client.py at line 1791.
What does _sleep_for_retry() call?
_sleep_for_retry() calls 2 function(s): _calculate_retry_timeout, _sleep_for_retry.
What calls _sleep_for_retry()?
_sleep_for_retry() is called by 2 function(s): _sleep_for_retry, request.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free