Skip to main content

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

Release files for edging 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for edging 0.1.0
File Size Uploaded
edging-0.1.0.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for edging 0.1.0
File Interpreter ABI Platform
edging-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.2 kB

Release files / edging-0.1.0.tar.gz

Download URL edging-0.1.0.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2b4660da3fa7a4a33b2da9d28fc1aa49e611a13a0e84290483ee9906d5a94926
BLAKE2b-256 checksum
How to use checksums
d1692dd6c0fc1145e26f627fe1c61537f7ee566ffad106934d86660c784901b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / edging-0.1.0-py3-none-any.whl

Download URL edging-0.1.0-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b2461d42163c36acd4438d9b4e881e1557e688a7e027279f7c58b59242bd998
BLAKE2b-256 checksum
How to use checksums
c71a3bc6f27a9444e272c0918c4ad6bd85aba8a1d5dd727c7337f835eee5e4f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page