retry_easy
A lightweight, zero-dependency retry decorator for synchronous and asynchronous Python functions.
Features
- No external runtime dependencies (standard library only)
- Supports both synchronous and asynchronous functions
- Configurable retry attempts, backoff, and jitter
- Fully typed (
ParamSpec,TypeVar) and compatible withmypy --strict - Safe handling of cancellation (
asyncio.CancelledError) - Small, readable implementation
Installation
pip install retry_easy
On Python < 3.10,
typing-extensionsis required forParamSpec. It is installed automatically.
Quick Start
Synchronous example
from retry_easy import retry
import requests
@retry(attempts=3, delay=1.0, backoff=2.0)
def fetch_data():
response = requests.get("https://api.example.com/data")
response.raise_for_status()
return response.json()
Asynchronous example
import asyncio
from retry_easy import retry
@retry(
attempts=5,
delay=0.5,
exceptions=(ConnectionError, TimeoutError),
jitter=0.2,
)
async def call_service():
await asyncio.sleep(0.1)
raise ConnectionError("Service temporarily unavailable")
API Reference
| Parameter | Type | Default | Description |
|---|---|---|---|
| attempts | int | 3 | Number of attempts (≥ 1) |
| delay | float | 1.0 | Initial delay in seconds (≥ 0) |
| backoff | float | 1.0 | Multiplier applied after each failure |
| exceptions | tuple[type[Exception], ...] | (Exception,) | Exceptions that trigger a retry |
| jitter | float | 0.0 | Random delay added to avoid synchronization |
Jitter behavior
wait_time = current_delay + random.uniform(0, jitter)
Why retry_easy?
| Use case | Typical approach | retry_easy |
|---|---|---|
| Simple retry logic | manual try/except loops | decorator |
| Async support | ad-hoc implementations | built-in |
| Lightweight dependency | heavy libraries | stdlib only |
| Type safety | partial typing | full typing |
This library targets the common use case: simple, readable retry logic without external dependencies.
Development
git clone https://github.com/undescoreF/retry_easy.git
cd retry_easy
pip install -e ".[dev]"
pytest tests/ -v
mypy src/
ruff check src/ tests/
Contributing
Contributions are welcome.
- Fork the repository
- Create a branch (
feature/my-change) - Commit changes with clear messages
- Open a Pull Request
- Ensure CI passes (tests, lint, type checks)
License
MIT License. See LICENSE for details.
Metadata
Release files for retry-easy 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| retry_easy-0.1.1.tar.gz | 6.8 kB | Without provenance | Details for retry_easy-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| retry_easy-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for retry_easy-0.1.1-py3-none-any.whl |
Total release size: 12.2 kB
Release files / retry_easy-0.1.1.tar.gz
| Download URL | retry_easy-0.1.1.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
35c9a18df704eb1582a02b0b89c4533910ad4245a77e037d127095ab39705c23
|
|
BLAKE2b-256 checksum How to use checksums |
5e95e8b9da5e51a2836648d2d91d22a7e561d8d9af38726b510f6c41a4dc07b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Release files / retry_easy-0.1.1-py3-none-any.whl
| Download URL | retry_easy-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd1d4d1936585e2efd6d706676ebbcfc4bee665f1c76c8cbc41027560b829b53
|
|
BLAKE2b-256 checksum How to use checksums |
a010c1b6fe18d5dba9210592fa9f9aba54cb00c9991ab771060d3c02a22adfee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Security for retry-easy 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.