Skip to main content

Loop frequency regulator for asyncio.

Project description

aiorate

Build Coverage Documentation PyPI version Status

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.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

aiorate-1.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file aiorate-1.0.0.tar.gz.

File metadata

  • Download URL: aiorate-1.0.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.22.0

File hashes

Hashes for aiorate-1.0.0.tar.gz
Algorithm Hash digest
SHA256 014c27db51dbdd44547debccf598fa157ebed1ab6f6fe97bb16a8c0cb4256b58
MD5 6946e00e44dca23d9e0df7e1da21e35d
BLAKE2b-256 5d1486a44fab4dd040225f7b9227db34aabd69be0a5b5478b93e2ffff8f9d8de

See more details on using hashes here.

File details

Details for the file aiorate-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: aiorate-1.0.0-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

Hashes for aiorate-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7f477559e43660994580be2f08d40d4ab6f1a7e2ba5d9a12ea4a11dbf7aa7b8
MD5 2a2ae2917470d44753962d1142f2495d
BLAKE2b-256 6cd36f3532ad21647b1d3b53201a09765588cb11b6de5f197111aabd7c37ca06

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page