New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

aiorate

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aiorate

Loop frequency regulator for asyncio.

  • 1.0.2
  • Source
  • PyPI
  • Socket score

Maintainers
1

aiorate

Build Coverage Documentation PyPI version

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

This project is archived as it has been superseded by loop-rate-limiters.

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

Here is what it looks like in practice:

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())

Check out the examples folder for more advance use cases, such as multiple loops running simultaneously at different rates.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc