Flexible, easy to use rate limiter
Project description
Rerate
Flexible rate limiter in Python, with (soon) multiple algorithms and backend stores.
Installing
pip install rerate
Usage
from rerate import limiter, RateLimitedException
from time import sleep
limit = Limiter(limit=2, period=1, store_option='REDIS', host='localhost', port=6379)
@limit
def example():
sleep(0.3)
print('hi')
for _ in range(100):
try:
example()
except RateLimitedException as e:
print('I got limited!')
Supported Storage Options
- Redis
- Local (dictionary)
Supported Algorithms
- Generic Cell Rate
Todo
- More backends, more algorithms
- Better exceptions
- Built in retry
- Async
Acknowledgments
A lot of the ideas/code is inspired by:
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
rerate-0.0.2.tar.gz
(4.6 kB
view hashes)
Built Distribution
rerate-0.0.2-py3-none-any.whl
(5.6 kB
view hashes)