Skip to main content Link Menu Expand (external link) Document Search Copy Copied

You can add hooks with either decorator style or app.add_hook(). The latter is more suitable in case you are creating an extension.

@app.on_worker_start
async def func(app, **server):
    print('before serving')

behaves the same way as:

app.add_hook(func, name='worker_start', priority=999)

Available names: 'worker_start', 'worker_stop', 'connect' and 'close'.