aiolimiter is an asyncio-compatible rate limiter library for Python, implementing a leaky bucket algorithm. It allows controlling the rate at which concurrent operations can acquire permits, preventing resource exhaustion or API overuse. The current version is 1.2.1, and it maintains a steady release cadence for bug fixes and minor enhancements.
pip install aiolimiterVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize `AsyncLimiter` and use it to control the rate of operations. It shows both the `async with` context manager for single-permit acquisition and the explicit `await limiter.acquire(count)` method for multiple permits.
Always use `await limiter.acquire(count)` for explicit permit acquisition.
Ensure `rate` is the quantity of permits and `period` is the time window. For 'X events per Y seconds', use `AsyncLimiter(X, Y)`.
Wrap `await limiter.acquire(count, block=False)` in a `try...except LimitReached` block to handle cases where permits cannot be acquired instantly.
pip install aiolimiter
from aiolimiter import AsyncLimiter
async with limiter:
# your code hereUpgrade your `aiolimiter` library to a version compatible with Python 3.10+ (e.g., `aiolimiter` 1.1.0 or newer). The fix involves `pip install --upgrade aiolimiter`.
Refactor your code to remove imports from `aiolimiter.compat`. If your application relies on specific functionality from this module, you might need to find an alternative implementation or downgrade `aiolimiter` to version `1.1.0` or older (`pip install aiolimiter==1.1.0`).
No dependency data recorded yet.