sanic-org/sanic

Graceful shutdown of signal handlers

Aperta

#2369 aperta il 12 gen 2022

 (5 commenti) (0 reazioni) (1 assegnatario)Python (1515 fork)batch import
beginnerhelp wanted

Metriche repository

Star
 (17.623 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor