the-retry
raw JSON → 0.1.1 verified Fri May 01 auth: no python
A simple retry decorator for both synchronous and asynchronous functions in Python. Current version 0.1.1, released 2024. Supports configurable retries, delays, backoff, and exception filtering. Low release cadence (last update 2024-09).
pip install the-retry Common errors
error ModuleNotFoundError: No module named 'the_retry' ↓
cause Package installed with pip but import uses hyphens or wrong name.
fix
Run
pip install the-retry and import as from the_retry import retry error TypeError: retry() got an unexpected keyword argument 'retry_count' ↓
cause Deprecated parameter `retry_count` used in newer version.
fix
Replace
retry_count with max_retries error AttributeError: module 'the_retry' has no attribute 'async_retry' ↓
cause Trying to import a non-existent submodule.
fix
Import AsyncRetryable directly:
from the_retry import AsyncRetryable Warnings
gotcha The package name uses hyphens on PyPI but underscores in Python imports. Use `import the_retry` not `import the-retry`. ↓
fix Use `from the_retry import retry`
gotcha The `delay` parameter default is 0, not 1. If you expect a small delay, set it explicitly. ↓
fix Add `delay=1` or desired delay to decorator
deprecated The `retry_count` parameter is deprecated in favor of `max_retries`. ↓
fix Replace `retry_count` with `max_retries`
Imports
- retry
from the_retry import retry - AsyncRetryable wrong
from the_retry.async_retry import AsyncRetryablecorrectfrom the_retry import AsyncRetryable
Quickstart
from the_retry import retry
import os
@retry(max_retries=3, delay=1, backoff=2, exceptions=(ConnectionError, TimeoutError))
def fetch_data(url: str) -> str:
return "data"
result = fetch_data("https://example.com")
print(result)