asyncio rate limiter, a leaky bucket implementation
Actively maintained. Last release 3 months ago, commits in 26 of the last 26 weeks. A safe choice.
pip install aiolimiteraiolimiter
Introduction
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.
Documentation
https://aiolimiter.readthedocs.io
Installation
$ pip install aiolimiter
The library requires Python 3.10 or newer.
Requirements
- Python >= 3.10
License
aiolimiter is offered under the MIT license.
Source code
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.