Registry / http-networking / rush
library2021.4.0pypypi✓ verified 23d ago

Rush is a Python library that provides a composable and extensible framework for implementing various rate limiting algorithms and storage backends. It includes a periodic interval rate limiter, a leaky bucket rate limiter (Generic Cell Ratelimiting Algorithm - GCRA), and supports Redis and in-memory dictionary storage. The library emphasizes type annotations and requires Python 3.6 or newer. The current version is 2021.4.0, released in April 2021.

pip install rush
INSTALL
IMPORT
SIG · RUSH
R
rush
http-networkingpythonv2021.4.0
Install
1.6s avg
Import
79ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2021.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.084s · 18.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.074s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

quota
from rush import quota
throttle
from rush import throttle
PeriodicLimiter
from rush.limiters import periodic
DictionaryStore
from rush.stores import dictionary

This quickstart demonstrates how to set up a basic periodic rate limiter using an in-memory dictionary store, defining a quota of 5000 requests per hour with a burst of 500. It then checks if an operation is limited and prints the result, remaining allowance, and reset time.

from rush import quota from rush import throttle from rush.limiters import periodic from rush.stores import dictionary t = throttle.Throttle( limiter=periodic.PeriodicLimiter( store=dictionary.DictionaryStore() ), rate=quota.Quota.per_hour( count=5000, burst=500, ), ) limit_result = t.check('expensive-operation/user@example.com', 1) print(f"Limited: {limit_result.limited}") print(f"Remaining: {limit_result.remaining}") print(f"Reset after: {limit_result.reset_after}")
Debug
Known issues
gotchaThe library's API is explicitly described as 'preliminary' and 'experimental'. While current imports are promised not to break, 'porcelain' (higher-level abstractions) may be added in future versions, potentially altering the recommended usage patterns.
fix
Refer to the official documentation for the latest recommended API usage and be prepared for potential changes to higher-level abstractions in future updates.
affects: 2021.4.0 and earlier
gotchaThe last release (2021.4.0) was in April 2021. While the project is marked as 'Production/Stable', development activity appears to be infrequent. Users seeking actively developed or frequently updated libraries might need to consider this pace.
fix
Evaluate if the existing feature set meets your needs and be aware that new features or rapid bug fixes may not be a priority for the maintainers.
affects: 2021.4.0 and later
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'rush_redis'
The `rush_redis` package, which provides Redis storage for Rush, is a separate dependency and is not installed by default with the main `rush` library.
fix
Install the `rush-redis` package using pip: `pip install rush-redis`
TypeError: __init__() missing 1 required positional argument: 'storage'
The `rush.Limiter` class constructor requires a storage backend instance (e.g., `MemoryStorage` or `RedisStorage`) to be explicitly passed as the `storage` argument.
fix
Instantiate a storage backend and pass it to the `Limiter` constructor: `limiter = Limiter(storage=MemoryStorage())`
TypeError: '<' not supported between instances of 'str' and 'int'
This error typically occurs when non-integer or non-numeric types are passed to arguments that expect numbers (e.g., `max_requests` in `Interval` or `rate` in `GCRA`), leading to comparison failures in the rate limiting logic.
fix
Ensure all numeric arguments to rate limiter configurations like `Interval` or `GCRA` are passed as integers or floats: `@limiter.limit(Interval(seconds=1, max_requests=5))`
Upgrade
Version history
2021.4.0latest on PyPI · released Apr 1, 2021
Audit
Dependencies
redisoptionalRequired for using the Redis storage backend.
Agent activity
28 hits · last 30 days
node
20
Meta
2
OpenAI (training)
1
Resources
rush — pip install rush · libregistry