Skip to main content

looper-佛跳墙活套:捕获asyncio报错。

Project description

aslooper

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

use looper

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

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

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

aslooper-1.2.1.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

aslooper-1.2.1-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

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