Skip to main content

Loop frequency regulator for asyncio.

Project description

aiorate

build Documentation PyPI package Status

Loop frequency regulator for asyncio with an API similar to rospy.Rate.

Installation

pip install aiorate

Usage

The [Rate](https://scaron.info/doc/aiorate/rate-limiter.html#aiorate.rate.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.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

aiorate-0.9.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aiorate-0.9.0.tar.gz
Algorithm Hash digest
SHA256 f92705aec688394d819b69edacf51de450a43c46655c6aa65f47efa47124d933
MD5 a16cd1fde97b96d75d956a79883bdeab
BLAKE2b-256 e827d3bafc5d67e5293c7af2268ccf72577af948f089281fa6661c2c2af2257f

See more details on using hashes here.

File details

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

File metadata

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

Hashes for aiorate-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd378b6d16a4c1b39aa3285ce1a59c640a4c885ed6fc15edba8af2eba43e8d0a
MD5 e168547758b5678b5ad7897f31ed89e5
BLAKE2b-256 58aa37b9c85f3f78c5922b3ef9787e0a8d957e3344def04abeffba4e26b37ad4

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