A simple function decorator that enables rate limiting using fixed window or sliding window strategies.
Project description
ratelimiter
A small Python library that provides simple function decorators for rate limiting using either a fixed-window (bursty) or a sliding-window (steady) strategy.
Example — Fixed window (bursty)
from ratelimiter import ratelimiter
@ratelimiter("fixed_window", calls=10, period=60)
def my_task(x):
print("task", x)
Example — Sliding window (steady, evenly spaced)
from ratelimiter import ratelimiter
@ratelimiter("sliding_window", calls=30, period=60, debug=True)
def api_call(payload):
return payload
Parameters Summary
| Parameter | Type | Description |
|---|---|---|
| calls | int |
Maximum number of calls allowed per window. |
| period | int | float |
Duration of the window in seconds. |
| offset_start / offset_end | (FixedWindow only) | Optional adjustments for the start and end edges of the window. |
| debug | bool |
Enables verbose logging to stdout for debugging and tracing sleep intervals. |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 ratelimits-0.1.1.tar.gz.
File metadata
- Download URL: ratelimits-0.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f761adb8554187657196ba2b333d429dffe269076286edfc7f8af16bcd275f5b
|
|
| MD5 |
bf71c8d6c5d5ba008e4f78527f2c18c4
|
|
| BLAKE2b-256 |
f43f88f51d11dfdb019d1aa96c76ec394b07e3d4d999bf14c5340b15a0a0f740
|
File details
Details for the file ratelimits-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ratelimits-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f2c84fe717daeb70a0c212b178bd6b0dfa5ac0f0fc81df064253d67ff73c481
|
|
| MD5 |
c168fb21406a1b60d1e725890221c2f2
|
|
| BLAKE2b-256 |
ff61a6f78bccb6ea6707bda2ad6815bbae3095ffbe5b121d162027fce51d2093
|