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.4.0.tar.gz
(10.2 kB
view hashes)
Built Distribution
Close
Hashes for loop_rate_limiters-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5dedfee55274d6fe4a87f8752da0008b0dac7bc36d2f27074e7aa797afffc06 |
|
MD5 | 1eb41a2a79af7b7e6766f45cd0e5b2d9 |
|
BLAKE2b-256 | f9996666d77ca5da39938720ca32309e83be9e343dd1671c130902bfcf2cb7ee |