Loop frequency regulator for asyncio.
Project description
aiorate
Loop frequency regulator for asyncio with an API similar to rospy.Rate
.
Installation
pip install aiorate
Usage
The Rate
class provides a non-blocking loop frequency limiter:
- Set the loop frequency in Hz at construction:
rate = aiorate.Rate(200.0)
- Call
await rate.sleep()
at every loop cycle
Example
import asyncio
import aiorate
async def main():
rate = aiorate.Rate(400.0) # Hz
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiorate-0.9.1.tar.gz
(12.2 kB
view details)
Built Distribution
File details
Details for the file aiorate-0.9.1.tar.gz
.
File metadata
- Download URL: aiorate-0.9.1.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40e0654352056e45f0fcd4dc54d870ce2cdc51f59d9f48e2e8f52b94205dedc8 |
|
MD5 | 7a7281c36437e63eeba6d47ef2f52581 |
|
BLAKE2b-256 | 3fbffb9288ea5cd5c2abb170ba0ec4d314a704b1ef9de2400bd9a821925caab3 |
File details
Details for the file aiorate-0.9.1-py3-none-any.whl
.
File metadata
- Download URL: aiorate-0.9.1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af41b6fe2f0dd02e536bf9f3ec9d6db21403c2101e6a555600190dc7069213e3 |
|
MD5 | 4126e9d4bd4630fe809004fed133cadf |
|
BLAKE2b-256 | 7a18c66b41b292f26fd1f4326fd7852ef4af336867fdda4e645954120a04d50a |