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-1.0.1.tar.gz
(14.3 kB
view details)
Built Distribution
File details
Details for the file aiorate-1.0.1.tar.gz
.
File metadata
- Download URL: aiorate-1.0.1.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6032ec4a08893839b76be87cc8e9e0a01e857e60374225dfc2243b1809c152b0 |
|
MD5 | 8d0b2bd9afef7e1bbe5bf7614bc661b0 |
|
BLAKE2b-256 | b974293fa18d20014cdec673b64c2dba61fea404edb0c82d6133348bc776bbed |
File details
Details for the file aiorate-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: aiorate-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.22.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b77690ad7ebd3feac98fcf0e0035d9d888a10df62fc748a45b449891f02e92b6 |
|
MD5 | 9bf89b1fd64db3bac41cf4028d8b0127 |
|
BLAKE2b-256 | 742a2d01a96417139325bc9b844b8fe9c85c052c049d2c6bec1f70dd6f7ff801 |