aio-rate-limiter
Rate limit a function using Redis as a backend. This is a smaller library modeled after python-redis-rate-limit but it uses aioredis. Supports Python 3.6+.
Installation
pip install aio-rate-limiter
Example
import logging
from aio_rate_limiter import RateLimiter, TooManyRequests
import aioredis
async def example():
pool = await aioredis.create_redis_pool("redis://localhost:6379")
try:
async with RateLimiter(
redis_pool,
# Rate limit requests to a resource
"name-of-external-system",
# Allow up to 100 requests in 60 seconds
max_requests=100,
time_window=60
):
async do_work()
except TooManyRequests:
logging.warning("Try again later")
Development
# Install poetry
pip install poetry
# Install all package dependencies
poetry install
# Launch a shell with dependencies available
poetry shell
# Run tests (requires Redis server running at localhost:6379)
pytest
# When you're ready to publish...
# Bump version
poetry version <version>
# Set your pypi token
export POETRY_PYPI_TOKEN_PYPI='...'
# Build and publish
poetry build
poetry publish
Metadata
Release files for aio-rate-limiter 0.1.2
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 | |
|---|---|---|---|---|
| aio-rate-limiter-0.1.2.tar.gz | 4.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aio_rate_limiter-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.2 kB
Release files / aio-rate-limiter-0.1.2.tar.gz
| Download URL | aio-rate-limiter-0.1.2.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6b85d9a956b221aa43404c1e1ffc9e74229a96504d168b192ee2f105d84748d
|
|
BLAKE2b-256 checksum How to use checksums |
ef28ec86596e2bbc74112b43897aaf834bf519668f033ff830930f16eda224f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.6.8 Darwin/19.6.0
|
Release files / aio_rate_limiter-0.1.2-py3-none-any.whl
| Download URL | aio_rate_limiter-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
540c00258a9a02712ee0b9d94f42b6771e25b7072d705a356bc5564b57118549
|
|
BLAKE2b-256 checksum How to use checksums |
d1cb73618ad27ff856014f9738d38c7943182f49966ce5ac87e1a4833f85d6a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.6.8 Darwin/19.6.0
|
Security for aio-rate-limiter 0.1.2
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.