Open
Description
Hi everyone. Looking at https://asgi.readthedocs.io/en/latest/specs/lifespan.html , I saw the following example implementation of the lifespan
type.
while True:
message = await receive()
if message['type'] == 'lifespan.startup':
... # Do some startup here!
await send({'type': 'lifespan.startup.complete'})
elif message['type'] == 'lifespan.shutdown':
... # Do some shutdown here!
await send({'type': 'lifespan.shutdown.complete'})
return
My naive implementation would consist of four flat lines of code only (receive, send, receive, send).
What is the reason for the while True
loop and the fail-safe message handling here? It's seems like I am missing something.
Metadata
Metadata
Assignees
Labels
No labels