Python Rate-Limiter using Leaky-Bucket Algorimth Family
Project description
Request Rate Limiter using Leaky-bucket algorimth
Introduction
This module can be used to apply rate-limit for API request, using leaky-bucket
algorimth. User defines window
duration and the limit of function calls within such interval.
Currently this package requires Redis
to work with.
Installation
$ pip install pyrate-limiter
Usage
from pyrate_limiter.core import RedisBucket as Bucket, HitRate
# Init bucket singleton
bucket = Bucket('redis-url', prefix='redis-prefix')
# Init rate_limiter
limiter = HitRate(
bucket,
capacity=10,
interval=60,
)
# Use as decorator
@limiter('redis-key')
def call(*args, **kwargs):
pass
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
pyrate-limiter-0.1.0.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for pyrate_limiter-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccc510d65f960b4a0eaeab0046f7618bdb6adb4e39b398477bb44b839c72f069 |
|
MD5 | 75d263ec3e7e92c2786c36faf8bdca78 |
|
BLAKE2b-256 | f2b979e2575c3e0c9c5734a6dbeff6b9c1bb85e8c524f87a9d109e02b6ee641d |