| 1 |
Metadata-Version: 2.1 |
| 2 |
Name: aiolimiter |
| 3 |
Version: 1.2.1 |
| 4 |
Summary: asyncio rate limiter, a leaky bucket implementation |
| 5 |
Home-page: https://github.com/mjpieters/aiolimiter |
| 6 |
License: MIT |
| 7 |
Keywords: asyncio,rate-limiting,leaky-bucket |
| 8 |
Author: Martijn Pieters |
| 9 |
Author-email: [email protected] |
| 10 |
Requires-Python: >=3.8,<4.0 |
| 11 |
Classifier: Framework :: AsyncIO |
| 12 |
Classifier: Intended Audience :: Developers |
| 13 |
Classifier: License :: OSI Approved :: MIT License |
| 14 |
Classifier: Programming Language :: Python :: 3 |
| 15 |
Classifier: Programming Language :: Python :: 3.8 |
| 16 |
Classifier: Programming Language :: Python :: 3.9 |
| 17 |
Classifier: Programming Language :: Python :: 3.10 |
| 18 |
Classifier: Programming Language :: Python :: 3.11 |
| 19 |
Classifier: Programming Language :: Python :: 3.12 |
| 20 |
Classifier: Programming Language :: Python :: 3.13 |
| 21 |
Project-URL: CI: Azure Pipelines, https://dev.azure.com/mjpieters/aiolimiter/_build |
| 22 |
Project-URL: Coverage: codecov, https://codecov.io/github/aiolimiter/aiosignal |
| 23 |
Project-URL: Documentation, http://aiolimiter.readthedocs.org/en/stable/ |
| 24 |
Project-URL: GitHub: issues, https://github.com/mjpieters/aiolimiter/issues |
| 25 |
Project-URL: Repository, https://github.com/mjpieters/aiolimiter |
| 26 |
Description-Content-Type: text/markdown |
| 27 |
|
| 28 |
# aiolimiter |
| 29 |
|
| 30 |
[![Azure Pipelines status for master branch][azure_badge]][azure_status] |
| 31 |
[![codecov.io status for master branch][codecov_badge]][codecov_status] |
| 32 |
[![Latest PyPI package version][pypi_badge]][aiolimiter_release] |
| 33 |
[![Latest Read The Docs][rtd_badge]][aiolimiter_docs] |
| 34 |
|
| 35 |
[azure_badge]: https://dev.azure.com/mjpieters/aiolimiter/_apis/build/status/CI?branchName=master |
| 36 |
[azure_status]: https://dev.azure.com/mjpieters/aiolimiter/_build/latest?definitionId=4&branchName=master "Azure Pipelines status for master branch" |
| 37 |
[codecov_badge]: https://codecov.io/gh/mjpieters/aiolimiter/branch/master/graph/badge.svg |
| 38 |
[codecov_status]: https://codecov.io/gh/mjpieters/aiolimiter "codecov.io status for master branch" |
| 39 |
[pypi_badge]: https://badge.fury.io/py/aiolimiter.svg |
| 40 |
[aiolimiter_release]: https://pypi.org/project/aiolimiter "Latest PyPI package version" |
| 41 |
[rtd_badge]: https://readthedocs.org/projects/aiolimiter/badge/?version=latest |
| 42 |
[aiolimiter_docs]: https://aiolimiter.readthedocs.io/en/latest/?badge=latest "Latest Read The Docs" |
| 43 |
|
| 44 |
## Introduction |
| 45 |
|
| 46 |
An efficient implementation of a rate limiter for asyncio. |
| 47 |
|
| 48 |
This project implements the [Leaky bucket algorithm][], giving you precise control over the rate a code section can be entered: |
| 49 |
|
| 50 |
```python |
| 51 |
from aiolimiter import AsyncLimiter |
| 52 |
|
| 53 |
# allow for 100 concurrent entries within a 30 second window |
| 54 |
rate_limit = AsyncLimiter(100, 30) |
| 55 |
|
| 56 |
|
| 57 |
async def some_coroutine(): |
| 58 |
async with rate_limit: |
| 59 |
# this section is *at most* going to entered 100 times |
| 60 |
# in a 30 second period. |
| 61 |
await do_something() |
| 62 |
``` |
| 63 |
|
| 64 |
It was first developed [as an answer on Stack Overflow][so45502319]. |
| 65 |
|
| 66 |
## Documentation |
| 67 |
|
| 68 |
https://aiolimiter.readthedocs.io |
| 69 |
|
| 70 |
## Installation |
| 71 |
|
| 72 |
```sh |
| 73 |
$ pip install aiolimiter |
| 74 |
``` |
| 75 |
|
| 76 |
The library requires Python 3.8 or newer. |
| 77 |
|
| 78 |
## Requirements |
| 79 |
|
| 80 |
- Python >= 3.8 |
| 81 |
|
| 82 |
## License |
| 83 |
|
| 84 |
`aiolimiter` is offered under the [MIT license](./LICENSE.txt). |
| 85 |
|
| 86 |
## Source code |
| 87 |
|
| 88 |
The project is hosted on [GitHub][]. |
| 89 |
|
| 90 |
Please file an issue in the [bug tracker][] if you have found a bug |
| 91 |
or have some suggestions to improve the library. |
| 92 |
|
| 93 |
## Developer setup |
| 94 |
|
| 95 |
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: |
| 96 |
|
| 97 |
```sh |
| 98 |
poetry install --with docs && poetry run doit devsetup |
| 99 |
``` |
| 100 |
|
| 101 |
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. |
| 102 |
|
| 103 |
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. |
| 104 |
|
| 105 |
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. |
| 106 |
|
| 107 |
[leaky bucket algorithm]: https://en.wikipedia.org/wiki/Leaky_bucket |
| 108 |
[so45502319]: https://stackoverflow.com/a/45502319/100297 |
| 109 |
[github]: https://github.com/mjpieters/aiolimiter |
| 110 |
[bug tracker]: https://github.com/mjpieters/aiolimiter/issues |
| 111 |
[poetry]: https://poetry.eustace.io/ |
| 112 |
|