skillfed

aioretry

Asyncio retry utility for Python 3.7+

aioretry v6.3.1 130.9K downloads/30d#11,618 on PyPI14
Permissive license Copyright (c) 2013 kaelzhang <>, contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) AGING released

What it is and what it does

aioretry is a decorator library that wraps async functions to automatically retry them on failure according to a policy you define. You supply a retry policy function that receives information about each failure (attempt count, exception, elapsed time) and returns a decision: either abandon and raise the exception, or sleep for a specified delay before retrying. The decorator handles the async sleep and retry loop for you.

It supports flexible policy definitions—functions, methods, class methods, or static methods—and optional before-retry callbacks for logging or side effects. The library works with instance methods, class methods, and standalone async functions, making it suitable for network operations, database queries, or any async task that might transiently fail.

Use it for:

  • Retry HTTP requests or API calls with exponential backoff when network timeouts or transient errors occur.
  • Automatically retry database connection attempts with configurable delays during service startup.
  • Implement circuit-breaker-like behavior by abandoning retries after a maximum failure count.
  • Log or monitor each retry attempt via a before_retry callback to track failure patterns.
  • Selectively retry only certain exception types while immediately failing on others.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a decorator-based retry mechanism for async functions in Python, allowing you to define custom retry policies that control when to retry, how long to wait between attempts, and when to give up.

Yes, if you need retry logic for async code. The library is lightweight, dependency-free, and straightforward to integrate. The aging maintenance status (540 days since release) is not a blocker—the API is stable and the recent repository activity suggests the maintainer is responsive. No known vulnerabilities. Install if your async workload benefits from configurable retry policies; skip if you prefer a heavier framework or have simple fixed-delay retry needs.

Install

aioretry on PyPI

pip

pip install aioretry

uv

uv add aioretry

poetry

poetry add aioretry

Installing aioretry

Before you install

Low friction: pure Python wheel with no runtime dependencies. Maintenance is aging—last release was 540 days ago, though the repository remains active with a recent commit on 2025-02-20.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions; suitable for both open-source and commercial projects.

Quickstart

from aioretry import retry, RetryInfo
import asyncio

def retry_policy(info: RetryInfo):
    return False, (info.fails - 1) % 3 * 0.1

@retry(retry_policy)
async def connect_to_server():
    pass

asyncio.run(connect_to_server())

Requires Python 3.7 or later; target function must be async or return an awaitable.

Verify before relying

  • Whether the aging maintenance status (540 days since last release) affects real-world reliability or if the stable API means infrequent updates are acceptable.
  • Performance characteristics under high concurrency or with very frequent retries.

Package facts

License Copyright (c) 2013 kaelzhang <>, contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 540 days since the last release
Last repo commit
First released
Downloads 130,941/month — #11,618 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: aioretry-6.3.1-py3-none-any.whl

Keywords: aioretry

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python Modules

Tags

asyncio retry decoratorasync function retry policyexponential backoff asyncretry logic for coroutinesasync error handling retryconfigurable retry strategyasyncio resilience pattern
async-utilitiesresilience-patternsdecorator-based

More Python Modules packages