Skip to main content

Loop rate limiters

Build Documentation Coverage Conda version PyPI version

Simple loop frequency regulators in Python with an API similar to rospy.Rate:

from loop_rate_limiters import RateLimiter
from time import perf_counter

rate = RateLimiter(frequency=400.0)
while True:
    print(f"Hello from loop at {perf_counter():.3f} s")
    rate.sleep()

A similar AsyncRateLimiter class is available for asynchronous code.

Installation

From conda-forge

conda install -c conda-forge loop-rate-limiters

From PyPI

pip install loop-rate-limiters

Usage

While the example above is synchronous, this library also provides an AsyncRateLimiter class for asyncio:

import asyncio
from loop_rate_limiters import AsyncRateLimiter

async def main():
    rate = AsyncRateLimiter(frequency=400.0)
    while True:
        loop_time = asyncio.get_event_loop().time()
        print(f"Hello from loop at {loop_time:.3f} s")
        await rate.sleep()

asyncio.run(main())

This can be used when there are several tasks executed in parallel at different frequencies.

See also

  • ischedule: single-thread interval scheduler in Python

Metadata

Release files for loop-rate-limiters 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for loop-rate-limiters 1.2.0
File Size Uploaded Provenance Actions
loop_rate_limiters-1.2.0.tar.gz 35.6 kB Without provenance Details for loop_rate_limiters-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for loop-rate-limiters 1.2.0
File Interpreter ABI Platform Actions
loop_rate_limiters-1.2.0-py3-none-any.whl Python 3 none any Details for loop_rate_limiters-1.2.0-py3-none-any.whl

Total release size: 46.5 kB

Release files / loop_rate_limiters-1.2.0.tar.gz

Download URL loop_rate_limiters-1.2.0.tar.gz
Size 35.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7187ec1f76f282ee7166d85c8e29eb13dd850422577decaf7e6bfc803173b421
BLAKE2b-256 checksum
How to use checksums
c7dcebbe468e7a71073879b322968a02e37594343ca2cc4b3ba65baf4db60adb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.4

Release files / loop_rate_limiters-1.2.0-py3-none-any.whl

Download URL loop_rate_limiters-1.2.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
482f720f409e05dfca8b7b63df180217afa9a51564def681853cb7370a020b74
BLAKE2b-256 checksum
How to use checksums
e26dd56be57340baf2e6f6361386f4c21b8b5e001251c64af954787f8d01ec78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.4

Security for loop-rate-limiters 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page