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
Release history Release notifications | RSS feed
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)