Loop rate limiters.
Project description
Loop rate limiters
Simple loop frequency regulators in Python with an API similar to rospy.Rate
.
Installation
pip install loop-rate-limiters
Usage
The RateLimiter
class provides a loop frequency limiter:
from loop_rate_limiters import RateLimiter
from time import perf_counter
rate = RateLimiter(frequency=400.0)
while True:
print(f"Hello from loop at {perf_counter():.3f} s")
rate.sleep()
asyncio
The AsyncRateLimiter
class provides a loop frequency limiter for asyncio:
import asyncio
from loop_rate_limiters import AsyncRateLimiter
async def main():
rate = AsyncRateLimiter(frequency=400.0)
while True:
loop_time = asyncio.get_event_loop().time()
print(f"Hello from loop at {loop_time:.3f} s")
await rate.sleep()
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for loop_rate_limiters-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c658caa7231d77d5d3def832bac74f551ad33aec2b0d780bbd184abfbebacbf |
|
MD5 | eff1fcac8569b608d642f0d2471327c5 |
|
BLAKE2b-256 | a5ccae0d5fb851ec40f8616049e1315ff49bc5fba0e42e6c4594420f85f0e3ac |