sanic-org/sanic

Graceful shutdown of signal handlers

开放

#2,369 创建于 2022年1月12日

 (5 条评论) (0 个反应) (1 位负责人)Python (1,515 个派生)batch import
beginnerhelp wanted

仓库指标

星标
 (17,623 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

When signals are added, we should run some sort of a cleanup like this on shutdown to make sure any custom signals are run. This also includes a suggestion that we identify them with a name: signal-XXXXX.

async def cleanup(app, _):
    for task in asyncio.all_tasks():
        if task.get_name().startswith("signal"):
          await task

贡献者指南