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.2.tar.gz
(13.7 kB
view details)
Built Distribution
File details
Details for the file aiorate-0.9.2.tar.gz
.
File metadata
- Download URL: aiorate-0.9.2.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 943640c0818e592fd967eb5f7ffd3a936384700b1427fd925ec397c4811fcacc |
|
MD5 | dcc08ca2422232b8670afc7e591a4f67 |
|
BLAKE2b-256 | 5fcf1eea17402e468caba9668959e2974e0149444c96df51d091fb4d54c1ca2f |
File details
Details for the file aiorate-0.9.2-py3-none-any.whl
.
File metadata
- Download URL: aiorate-0.9.2-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c17e8262d1bb70e622c68746e0b45c8f29f4e6ccd1b785ecd04902e4be470eeb |
|
MD5 | e41eed07b19b096ab4921468702283b7 |
|
BLAKE2b-256 | 7e1a6624626f103f7095aae9269bd1bd371e7bda20ab63f5783f5bfb4fbf2919 |