retry-async
raw JSON → 0.1.4 verified Fri May 01 auth: no python
A lightweight Python library for retrying async functions with configurable backoff, jitter, and retry conditions. Supports both asyncio and trio. Current version: 0.1.4. Release cadence: intermittent.
pip install retry-async Common errors
error TypeError: 'coroutine' object is not callable ↓
cause Placing @retry_async on a non-async function or forgetting to await inside a lambda.
fix
Use async def and proper await syntax.
error AttributeError: module 'retry_async' has no attribute 'retry' ↓
cause Importing the wrong name; the function is 'retry_async'.
fix
from retry_async import retry_async
error TypeError: retry_async() missing 1 required positional argument: 'func' ↓
cause Using @retry_async without arguments but without parentheses, or incorrect syntax.
fix
Use @retry_async() or pass params: @retry_async(max_tries=3)
Warnings
gotcha The decorator must be placed on a coroutine function; using it on a regular function will raise TypeError. ↓
fix Ensure the decorated function is async def.
gotcha The `max_tries` parameter includes the initial attempt, so max_tries=1 means no retry. ↓
fix Set max_tries to the total number of attempts (initial + retries).
breaking In version 0.1.0, the default backoff was linear, but changed to exponential in 0.1.1. ↓
fix If you relied on linear backoff, set backoff=1.0 explicitly.
Imports
- retry_async wrong
from retry_async import retrycorrectfrom retry_async import retry_async
Quickstart
import asyncio
from retry_async import retry_async
async def unreliable():
raise ValueError("Oops")
@retry_async(max_tries=3, delay=1.0, backoff=2.0)
async def main():
return await unreliable()
if __name__ == '__main__':
asyncio.run(main())