Loop-rate-limiters (current version 1.2.0) is a Python library providing simple frequency regulators for loops, offering an API similar to `rospy.Rate`. It supports both synchronous and asynchronous (asyncio) operations, ensuring code execution at a desired frequency. The library maintains an active development pace with regular patch and minor releases to introduce new features, fix bugs, and improve logging.
pip install loop-rate-limitersVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the usage of `AsyncRateLimiter` to regulate the frequency of an asynchronous loop. A synchronous `RateLimiter` example is also included to show its basic usage.
Upgrade your Python environment to version 3.9 or higher.
If your code relies on catching `RuntimeError` for `AsyncRateLimiter`'s loop status, update your error handling to check for warnings or ensure an `asyncio` loop is always active. Ensure you use `asyncio.run()` or a similar mechanism.
Do not attempt to modify attributes like `rate.period` or `rate.slack` directly after initialization. Instead, set them during the `RateLimiter` or `AsyncRateLimiter` constructor.
Upgrade to version 1.1.1 or newer to ensure lateness warnings report correct (positive) durations.
Upgrade to version 1.2.0 or newer to benefit from the fix for the `AsyncRateLimiter` initialization bug.
Ensure your Python environment is 3.9 or newer (`python --version`). If it is, reinstall the package: `pip install --upgrade loop-rate-limiters`.
Always run asynchronous code, including `AsyncRateLimiter`, within an `asyncio` event loop (e.g., by calling `asyncio.run(your_async_function())`). If on v1.1.0+, check logs for warnings instead of expecting an exception.
These attributes can only be set during the object's initialization (e.g., `rate = RateLimiter(frequency=10.0)`). If you need to change the frequency, create a new `RateLimiter` instance.
Upgrade to `loop-rate-limiters` version 1.1.1 or higher to resolve this issue and get correctly signed lateness warnings.
No dependency data recorded yet.