is while True: await receive() correnct?
#2777
-
|
uvicorn/docs/concepts/lifespan.md Line 77 in ae56d07 async def app(scope, receive, send):
if scope['type'] == 'lifespan':
while True:
message = await receive()
...Seems to me it would block the entire server. If it's correct, can someone explain why? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
It looks a correct pattern. And similar to the example in ASGI docs: https://asgi.readthedocs.io/en/latest/specs/lifespan.html
No. Which the blocking things? The It should be easy to verify this. |
Beta Was this translation helpful? Give feedback.
It looks a correct pattern. And similar to the example in ASGI docs: https://asgi.readthedocs.io/en/latest/specs/lifespan.html
No. Which the blocking things? The
app()task will be just alive until shutdown. But it won't interfere server to create anotherapp()instance for each request event.It should be easy to verify this.