Skip to main content

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

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.3.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aslooper-1.3.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file aslooper-1.3.0.tar.gz.

File metadata

  • Download URL: aslooper-1.3.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.9 Linux/6.8.11-amd64

File hashes

Hashes for aslooper-1.3.0.tar.gz
Algorithm Hash digest
SHA256 f90f8036af2de907a2192537e5adcde4c72d943219be7f1d568d91e9122102db
MD5 d2fc1ea0b54891d96790a4c8695aa7d2
BLAKE2b-256 bf2b864388fb81705c7c4c5d1c3d6fa0ecc0bb1c8a6c504dc46aa54127eda897

See more details on using hashes here.

File details

Details for the file aslooper-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: aslooper-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.9 Linux/6.8.11-amd64

File hashes

Hashes for aslooper-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8bf7ab3794046cf8768eea881fecaee4e5cd1182adf3320af74a1341a1063f8
MD5 8e9e2370101d38e702f08d77823265a2
BLAKE2b-256 7bb14f6ed10799cd51a90780cd638d8777d078a0e4c592b0754a480aef857e3d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page