An efficient implementation of a rate limiter for asyncio.
An efficient implementation of a rate limiter for asyncio.
An efficient implementation of a rate limiter for asyncio.
This project implements the Leaky bucket algorithm, giving you precise control over the rate a code section can be entered:
from aiolimiter import AsyncLimiter
# allow for 100 concurrent entries within a 30 second window
rate_limit = AsyncLimiter(100, 30)
async def some_coroutine():
async with rate_limit:
# this section is *at most* going to entered 100 times
# in a 30 second period.
await do_something()
It was first developed as an answer on Stack Overflow.
https://aiolimiter.readthedocs.io
$ pip install aiolimiter
The library requires Python 3.10 or newer.
aiolimiter is offered under the MIT license.
The project is hosted on GitHub.
Please file an issue in the bug tracker if you have found a bug or have some suggestions to improve the library.
This project uses uv to manage dependencies, testing and releases. Make sure you have installed that tool, then run the following command to get set up:
uv sync
Tests are run with pytest and tox. Releases are made managed by a GitHub Actions workflow. Code quality is maintained with ruff and pyright, and prek runs quick checks to maintain the standards set.
A Taskfile is provided that defines specific tasks such as linting, formatting or previewing the documentation:
…
No open issues yet, or sync has not completed.