The `ratelimiter` library provides a simple mechanism for rate-limiting operations in Python, both synchronously (using decorators or context managers) and asynchronously (using `async with`). It allows developers to control the frequency of function calls, often useful when interacting with APIs that have usage limits. The current version is 1.2.0.post0, and the project has not seen updates since 2017, suggesting it is no longer actively maintained.
pip install ratelimiterVerified import paths — ran on the pinned version, not inferred.
Demonstrates both decorator and context manager usage of `RateLimiter`. It defines a limit of 2 calls per 3-second period and includes a callback to inform when rate-limiting occurs. The `time.sleep` calls simulate work and illustrate how the limiter pauses execution.
For new projects, evaluate actively maintained alternatives. For existing projects, thoroughly test on your target Python versions.
Ensure your callback implementation correctly handles the execution context (thread for sync, coroutine for async) and potential blocking behavior. If using `async with`, make sure the callback is `async def`.
For distributed systems, consider libraries or custom implementations that integrate with shared backends like Redis or databases (e.g., `limits` or `pyrate-limiter` with appropriate backends).
No dependency data recorded yet.