aiorate


Nameaiorate JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryLoop frequency regulator for asyncio.
upload_time2022-12-07 15:21:53
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords rate loop frequency regulator
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aiorate

[![Build](https://img.shields.io/github/workflow/status/tasts-robots/aiorate/CI)](https://github.com/tasts-robots/aiorate/actions)
[![Coverage](https://coveralls.io/repos/github/tasts-robots/aiorate/badge.svg?branch=master)](https://coveralls.io/github/tasts-robots/aiorate?branch=master)
[![Documentation](https://img.shields.io/badge/docs-online-brightgreen?logo=read-the-docs&style=flat)](https://tasts-robots.org/doc/aiorate/)
[![PyPI version](https://img.shields.io/pypi/v/aiorate)](https://pypi.org/project/aiorate/)

Loop frequency regulator for [asyncio](https://docs.python.org/3/library/asyncio.html) with an API similar to [``rospy.Rate``](https://wiki.ros.org/rospy/Overview/Time#Sleeping_and_Rates).

**This project is archived as it has been superseded by [loop-rate-limiters](https://github.com/stephane-caron/loop-rate-limiters).**

## Installation

```sh
pip install aiorate
```

## Usage

The [``Rate``](https://tasts-robots.org/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

Here is what it looks like in practice:

```python
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](examples/) folder for more advance use cases, such as multiple loops running simultaneously at different rates.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "aiorate",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "St\u00e9phane Caron <stephane.caron@normalesup.org>",
    "keywords": "rate,loop,frequency,regulator",
    "author": null,
    "author_email": "St\u00e9phane Caron <stephane.caron@normalesup.org>",
    "download_url": "https://files.pythonhosted.org/packages/d2/c1/317c3d4c2d2f8ade5ee731e4ee1b6df1444ebffe0d19a83cc4912187248c/aiorate-1.0.2.tar.gz",
    "platform": null,
    "description": "# aiorate\n\n[![Build](https://img.shields.io/github/workflow/status/tasts-robots/aiorate/CI)](https://github.com/tasts-robots/aiorate/actions)\n[![Coverage](https://coveralls.io/repos/github/tasts-robots/aiorate/badge.svg?branch=master)](https://coveralls.io/github/tasts-robots/aiorate?branch=master)\n[![Documentation](https://img.shields.io/badge/docs-online-brightgreen?logo=read-the-docs&style=flat)](https://tasts-robots.org/doc/aiorate/)\n[![PyPI version](https://img.shields.io/pypi/v/aiorate)](https://pypi.org/project/aiorate/)\n\nLoop frequency regulator for [asyncio](https://docs.python.org/3/library/asyncio.html) with an API similar to [``rospy.Rate``](https://wiki.ros.org/rospy/Overview/Time#Sleeping_and_Rates).\n\n**This project is archived as it has been superseded by [loop-rate-limiters](https://github.com/stephane-caron/loop-rate-limiters).**\n\n## Installation\n\n```sh\npip install aiorate\n```\n\n## Usage\n\nThe [``Rate``](https://tasts-robots.org/doc/aiorate/rate-limiter.html#aiorate.rate.Rate) class provides a non-blocking loop frequency limiter:\n\n* Set the loop frequency in Hz at construction: ``rate = aiorate.Rate(200.0)``\n* Call ``await rate.sleep()`` at every loop cycle\n\nHere is what it looks like in practice:\n\n```python\nimport asyncio\nimport aiorate\n\nasync def main():\n    rate = aiorate.Rate(400.0)  # Hz\n    while True:\n        loop_time = asyncio.get_event_loop().time()\n        print(f\"Hello from loop at {loop_time:.3f} s\")\n        await rate.sleep()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\nCheck out the [examples](examples/) folder for more advance use cases, such as multiple loops running simultaneously at different rates.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Loop frequency regulator for asyncio.",
    "version": "1.0.2",
    "split_keywords": [
        "rate",
        "loop",
        "frequency",
        "regulator"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "md5": "e8f228618b5d4bb2b42a690201ddeb32",
                "sha256": "d6fdf4e90463f1ce5441709fc50129d84f314ce1a788acafaa79d0ee0cd4af38"
            },
            "downloads": -1,
            "filename": "aiorate-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e8f228618b5d4bb2b42a690201ddeb32",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 8774,
            "upload_time": "2022-12-07T15:21:50",
            "upload_time_iso_8601": "2022-12-07T15:21:50.573647Z",
            "url": "https://files.pythonhosted.org/packages/dd/d4/dc52c148fd12f95d14a0edf32fad83123bed1dac99bfaf61aad7a0df2921/aiorate-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "md5": "06d6a006b9b71fe9bc443f32aec9337f",
                "sha256": "5d3f2d4f84de533ebfb902a4f4d3c3057f455ccbd2b261a76cb8f653105aa1eb"
            },
            "downloads": -1,
            "filename": "aiorate-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "06d6a006b9b71fe9bc443f32aec9337f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 14843,
            "upload_time": "2022-12-07T15:21:53",
            "upload_time_iso_8601": "2022-12-07T15:21:53.088082Z",
            "url": "https://files.pythonhosted.org/packages/d2/c1/317c3d4c2d2f8ade5ee731e4ee1b6df1444ebffe0d19a83cc4912187248c/aiorate-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-07 15:21:53",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "aiorate"
}
        
Elapsed time: 0.01622s