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 rushVerified import paths — ran on the pinned version, not inferred.
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.
Refer to the official documentation for the latest recommended API usage and be prepared for potential changes to higher-level abstractions in future updates.
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.
Install the `rush-redis` package using pip: `pip install rush-redis`
Instantiate a storage backend and pass it to the `Limiter` constructor: `limiter = Limiter(storage=MemoryStorage())`
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))`