Rate limiting that approaches but never exceeds a threshold.
Project description
edging
Rate limiting that approaches but never exceeds a threshold. Implements a
classic token-bucket limiter with an optional hold_at_threshold() mode
for steady approach without burst overshoot.
Install
pip install edging
Usage
from edging import TokenBucket, RateLimitExceeded
bucket = TokenBucket(rate=5.0, capacity=5.0).hold_at_threshold(True)
assert bucket.acquire(1.0) is True
assert bucket.tokens() < 5.0
try:
# exhaust then fail closed without blocking
for _ in range(10):
bucket.acquire(1.0, blocking=False)
except RateLimitExceeded as e:
assert e.retry_after > 0
Roadmap
This is an early 0.1.0 release with active development planned:
- Async acquire APIs
- Shared / distributed backends
- Adaptive threshold policies
Author
Coldbricks — coldbricks@gmail.com
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
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 edging-0.1.0.tar.gz.
File metadata
- Download URL: edging-0.1.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b4660da3fa7a4a33b2da9d28fc1aa49e611a13a0e84290483ee9906d5a94926
|
|
| MD5 |
0200162c89f320d1b721c0f6022b9b6b
|
|
| BLAKE2b-256 |
d1692dd6c0fc1145e26f627fe1c61537f7ee566ffad106934d86660c784901b4
|
File details
Details for the file edging-0.1.0-py3-none-any.whl.
File metadata
- Download URL: edging-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b2461d42163c36acd4438d9b4e881e1557e688a7e027279f7c58b59242bd998
|
|
| MD5 |
c1453763a06747625c1f2092ebe395e6
|
|
| BLAKE2b-256 |
c71a3bc6f27a9444e272c0918c4ad6bd85aba8a1d5dd727c7337f835eee5e4f9
|