A Token Bucket Implementation for Python Web Apps
The token-bucket package provides an implementation of the token bucket algorithm suitable for use in web applications for shaping or policing request rates. This implementation does not require the use of an independent timer thread to manage the bucket state.
Compared to other rate-limiting algorithms that use a simple counter, the token bucket algorithm provides the following advantages:
The thundering herd problem is avoided since bucket capacity is replenished gradually, rather than being immediately refilled at the beginning of each epoch as is common with simple fixed window counters.
Burst duration can be explicitly controlled.
Moving window algorithms are resistant to bursting, but at the cost of additional processing and memory overhead vs. the token bucket algorithm which uses a simple, fast counter per key. The latter approach does allow for bursting, but only for a controlled duration.
Metadata
Release files for token-bucket 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| token_bucket-0.4.0.tar.gz | 12.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| token_bucket-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.9 kB
Release files / token_bucket-0.4.0.tar.gz
| Download URL | token_bucket-0.4.0.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80f94bbe85be8f5adccd51330c26d07e6efdf6e154657cf107f7e65ce510d886
|
|
BLAKE2b-256 checksum How to use checksums |
8d17bf09fd3373ff3098151978ca2abde0b125589459a4724885731f7f877c0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / token_bucket-0.4.0-py3-none-any.whl
| Download URL | token_bucket-0.4.0-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16a90125a696b9e22e3e2f20ea9060a5abf07572bf91500142e3b3747d30e568
|
|
BLAKE2b-256 checksum How to use checksums |
c6850a9e1f712f1be611f6ca9db2849925c483bcda41674412013e27e3fcd0a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for token-bucket 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.