aioburst
A library to optimize the speed of rate limited async calls, by alternating between bursts and sleeps.
Usage
Install the package using pip:
pip install aioburst
Import the limiter:
from aioburst import aioburst
Instantiate the limiter using the create method, setting the limit (number of calls) and period (period over
which the number of calls are restricted):
limiter = AIOBurst.create(limit=10, period=1.0)
async with limiter:
...
The code above would allow 10 asynchronous entries (into the context manager) without any limit. Then it adds
"sleepers" for the next calls. The sleeper tells the next entry when it can start. The 11th call gets the sleeper
set by the 1st call that returned and waits until the period has elapsed. This approach ensures that there are
never more than limit simultaneous calls but that the next call can start as soon as possible. The result is that
in a sliding window of period you should see exactly limit calls as active, regardless of how fast or slow any
individual call returns.
You can also stack limiters:
limiter1 = AIOBurst.create(limit=10, period=1.0)
limiter2 = AIOBurst.create(limit=100, period=60.0)
async with limiter1:
async with limiter2:
...
Use this for cases where an API has a two-level rate limit like 10 calls per second or 100 calls per minute---both limits will be respected. The stack is also idempotent, meaning that whichever way you stack the limiters, both limits will be respected:
limiter1 = AIOBurst.create(limit=10, period=1.0)
limiter2 = AIOBurst.create(limit=100, period=60.0)
async with limiter1:
async with limiter2:
...
# The limit above will do the exact same thing as the limit below
async with limiter2:
async with limiter1:
...
Metadata
Release files for aioburst 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| aioburst-0.2.0.tar.gz | 3.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aioburst-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.9 kB
Release files / aioburst-0.2.0.tar.gz
| Download URL | aioburst-0.2.0.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29c7e3289d7e935e974009a846a8da55fefa45214780a15949517fabf0e4aad2
|
|
BLAKE2b-256 checksum How to use checksums |
95bdfe5671cddc5a72585f2f9dc101065d93d583367968a887f020fae0a54ffa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.7 Linux/5.4.0-1090-azure
|
Release files / aioburst-0.2.0-py3-none-any.whl
| Download URL | aioburst-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e036e68e504b8031ebfe260bb66ac8d8aaff4c39f5f4332cf52c814109da8b1
|
|
BLAKE2b-256 checksum How to use checksums |
64568b44c64452352ede6e8da85ad604325c89e4d18b38a5a200b59ec75ecd12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.7 Linux/5.4.0-1090-azure
|
Security for aioburst 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.