-
Notifications
You must be signed in to change notification settings - Fork 134
Open
Description
Does hypercorn have before/on_start and after/on_end async hooks that don't get called for each worker spawned? If not, how do you suggest achieving this?
Here is a POC,
from asyncio import sleep
from quart import Quart
app = Quart(__name__)
@app.route('/')
async def hello():
return 'hello'
@app.before_serving
async def on_start():
await sleep(0.01)
print('Wish to only print once, on start')
@app.after_serving
async def on_end():
await sleep(0.01)
print('Wish to only print once, on end') hypercorn -w 3 -b 0.0.0.0:5000 poc:app
Wish to only print once, on start
Wish to only print once, on start
[2026-01-03 13:26:54 +0800] [112664] [INFO] Running on http://0.0.0.0:5000 (CTRL + C to quit)
[2026-01-03 13:26:54 +0800] [112662] [INFO] Running on http://0.0.0.0:5000 (CTRL + C to quit)
Wish to be only print once, on start
[2026-01-03 13:26:54 +0800] [112663] [INFO] Running on http://0.0.0.0:5000 (CTRL + C to quit)
^CWish to only print once, on end
Wish to only print once, on end
Wish to only print once, on endMetadata
Metadata
Assignees
Labels
No labels