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 details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rerate-0.0.2.tar.gz.
File metadata
- Download URL: rerate-0.0.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d349404f6283b3a8abcfd5e4ea802875bb9216bdf07d6ad70ff5486e3c38bb4
|
|
| MD5 |
3c1b4ce2781c5a1f345fc2330f00ff7d
|
|
| BLAKE2b-256 |
f89b9cc7782dd020e5a50a2710f345f1f2c56689bb4b58808f7e5d47ddc3adbb
|
File details
Details for the file rerate-0.0.2-py3-none-any.whl.
File metadata
- Download URL: rerate-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5943384a843c5f779b2a8bd014e1e5bc5bf91bf4dcbb547fd3c51c038e11b53a
|
|
| MD5 |
492e0237885bfcce8e31e9f3395243d6
|
|
| BLAKE2b-256 |
c673f464407d1459e984e3fe7b9b4e0c4422486a220c9167bb081401de487f5f
|