asyncio rate limiter, a leaky bucket implementation
Project description
aiolimiter
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.8 or newer.
Requirements
- Python >= 3.8
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.
Developer setup
This project uses poetry to manage dependencies, testing and releases. Make sure you have installed that tool, then run the following command to get set up:
poetry install --with docs && poetry run doit devsetup
Apart from using poetry run doit devsetup, you can either use poetry shell to enter a shell environment with a virtualenv set up for you, or use poetry run ... to run commands within the virtualenv.
Tests are run with pytest and tox. Releases are made with poetry build and poetry publish. Code quality is maintained with flake8, black and mypy, and pre-commit runs quick checks to maintain the standards set.
A series of doit tasks are defined; run poetry run doit list (or doit list with poetry shell activated) to list them. The default action is to run a full linting, testing and building run. It is recommended you run this before creating a pull request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiolimiter-1.2.1.tar.gz.
File metadata
- Download URL: aiolimiter-1.2.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e02a37ea1a855d9e832252a105420ad4d15011505512a1a1d814647451b5cca9
|
|
| MD5 |
82306409ed14b7d46929606143a7ee65
|
|
| BLAKE2b-256 |
f123b52debf471f7a1e42e362d959a3982bdcb4fe13a5d46e63d28868807a79c
|
File details
Details for the file aiolimiter-1.2.1-py3-none-any.whl.
File metadata
- Download URL: aiolimiter-1.2.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3f249e9059a20badcb56b61601a83556133655c11d1eb3dd3e04ff069e5f3c7
|
|
| MD5 |
e4130ada5180306dbd8d4a164d5ddb36
|
|
| BLAKE2b-256 |
f3badf6e8e1045aebc4778d19b8a3a9bc1808adb1619ba94ca354d9ba17d86c3
|