--- id: aioretry version: "6.3.1" 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) license_treatment: permissive maintenance: aging --- # aioretry — Asyncio retry utility for Python 3.7+ License: permissive · Maintenance: aging · Downloads: 130.9K/mo ## 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 above — 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 pip install aioretry uv add aioretry 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_current - Install friction: low - Maintenance: aging - Downloads: 130.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags asyncio retry decorator, async function retry policy, exponential backoff async, retry logic for coroutines, async error handling retry, configurable retry strategy, asyncio resilience pattern, async-utilities, resilience-patterns, decorator-based [View on SkillFed](https://skillfed.io/packages/aioretry) · [View on PyPI](https://pypi.org/project/aioretry/)