aslooper


Nameaslooper JSON
Version 1.3.0 PyPI version JSON
download
home_pagehttps://vastxiao.github.io/
Summarylooper-佛跳墙活套:捕获asyncio cancel报错。
upload_time2024-08-17 04:03:01
maintainerNone
docs_urlNone
authorvastxiao
requires_python>=3.11
licenseMIT
keywords async asyncio loop
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aslooper

> looper
> Used to cancel all running tasks after catching SIGINT, SIGTERM signals,
> Quit running without raise asyncio cancelled error.

## use looper

```python
import asyncio
from aslooper import looper


async def run(i):
    while True:
        print(f"{i} running.")
        await asyncio.sleep(1)


@looper()
async def main():
    tasks = [run(i) for i in range(3)]
    await asyncio.gather(*tasks)


asyncio.run(main())
```

## run with a call

```python
import asyncio
from aslooper import looper


async def run(i):
    while True:
        print(f"{i} running.")
        await asyncio.sleep(1)


def some_call():
    print("some_call")


@looper(some_call)
async def main():
    while True:
        print("run something.")
        await asyncio.sleep(1)


asyncio.run(main())
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://vastxiao.github.io/",
    "name": "aslooper",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "async, asyncio, loop",
    "author": "vastxiao",
    "author_email": "vastxiao@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bf/2b/864388fb81705c7c4c5d1c3d6fa0ecc0bb1c8a6c504dc46aa54127eda897/aslooper-1.3.0.tar.gz",
    "platform": null,
    "description": "# aslooper\n\n> looper\n> Used to cancel all running tasks after catching SIGINT, SIGTERM signals,\n> Quit running without raise asyncio cancelled error.\n\n## use looper\n\n```python\nimport asyncio\nfrom aslooper import looper\n\n\nasync def run(i):\n    while True:\n        print(f\"{i} running.\")\n        await asyncio.sleep(1)\n\n\n@looper()\nasync def main():\n    tasks = [run(i) for i in range(3)]\n    await asyncio.gather(*tasks)\n\n\nasyncio.run(main())\n```\n\n## run with a call\n\n```python\nimport asyncio\nfrom aslooper import looper\n\n\nasync def run(i):\n    while True:\n        print(f\"{i} running.\")\n        await asyncio.sleep(1)\n\n\ndef some_call():\n    print(\"some_call\")\n\n\n@looper(some_call)\nasync def main():\n    while True:\n        print(\"run something.\")\n        await asyncio.sleep(1)\n\n\nasyncio.run(main())\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "looper-\u4f5b\u8df3\u5899\u6d3b\u5957\uff1a\u6355\u83b7asyncio cancel\u62a5\u9519\u3002",
    "version": "1.3.0",
    "project_urls": {
        "Homepage": "https://vastxiao.github.io/"
    },
    "split_keywords": [
        "async",
        " asyncio",
        " loop"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7bb14f6ed10799cd51a90780cd638d8777d078a0e4c592b0754a480aef857e3d",
                "md5": "8e9e2370101d38e702f08d77823265a2",
                "sha256": "c8bf7ab3794046cf8768eea881fecaee4e5cd1182adf3320af74a1341a1063f8"
            },
            "downloads": -1,
            "filename": "aslooper-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8e9e2370101d38e702f08d77823265a2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 4625,
            "upload_time": "2024-08-17T04:02:59",
            "upload_time_iso_8601": "2024-08-17T04:02:59.971490Z",
            "url": "https://files.pythonhosted.org/packages/7b/b1/4f6ed10799cd51a90780cd638d8777d078a0e4c592b0754a480aef857e3d/aslooper-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bf2b864388fb81705c7c4c5d1c3d6fa0ecc0bb1c8a6c504dc46aa54127eda897",
                "md5": "d2fc1ea0b54891d96790a4c8695aa7d2",
                "sha256": "f90f8036af2de907a2192537e5adcde4c72d943219be7f1d568d91e9122102db"
            },
            "downloads": -1,
            "filename": "aslooper-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d2fc1ea0b54891d96790a4c8695aa7d2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 3806,
            "upload_time": "2024-08-17T04:03:01",
            "upload_time_iso_8601": "2024-08-17T04:03:01.402607Z",
            "url": "https://files.pythonhosted.org/packages/bf/2b/864388fb81705c7c4c5d1c3d6fa0ecc0bb1c8a6c504dc46aa54127eda897/aslooper-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-17 04:03:01",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "aslooper"
}
        
Elapsed time: 4.48994s