Ratelim is a simple Python library (version 0.1.6, last released Feb 2015) that provides decorators to limit the number of times a function can be called within a specific time interval. It's particularly useful for respecting rate limits of external APIs. It supports both greedy and patient rate limiting strategies and preserves the function signature. This library has not been updated since 2015.
pip install ratelimVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use the `@rate_limited` decorator to restrict function calls. It also shows how to catch `RateLimitException` and implement basic retry logic, as `ratelim` itself does not provide built-in `sleep_and_retry` functionality.
Consider using alternative, actively maintained libraries for rate limiting if starting a new project or if long-term support is crucial. If using `ratelim`, be aware of potential compatibility issues with newer Python versions and the lack of new features/bug fixes.
Wrap calls to rate-limited functions in a `try...except RateLimitException` block and implement custom sleep/retry logic, as shown in the quickstart example.
For distributed or multi-process rate limiting, consider libraries that offer shared state backends (e.g., Redis, database), such as `pyrate-limiter` or `upstash-ratelimit`.
No dependency data recorded yet.