Loop rate limiters.
Project description
Loop rate limiters
Simple loop frequency regulators in Python with an API similar to rospy.Rate
.
Installation
From conda-forge:
conda install loop-rate-limiters -c conda-forge
From PyPI:
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
loop-rate-limiters-0.3.0.tar.gz
(10.1 kB
view hashes)
Built Distribution
Close
Hashes for loop_rate_limiters-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8731e6f429f59727f52054b79e18fa45eddda8ce16d37ec308e77826209037c1 |
|
MD5 | 06a29893c8dfa74857b4b01853855014 |
|
BLAKE2b-256 | a78255210b852c0a0606deb702618dcb0c7243d032247a1986020334f30df6e6 |