From c4a021ee9c4d760bbe4066887ca816fc7c718f98 Mon Sep 17 00:00:00 2001 From: mozartilize Date: Fri, 1 Jul 2022 22:49:35 +0700 Subject: [PATCH] Handle ASGI lifespan when running with a secondary ASGI app (#284) --- src/engineio/async_drivers/asgi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engineio/async_drivers/asgi.py b/src/engineio/async_drivers/asgi.py index 092f4c2..0e9b733 100644 --- a/src/engineio/async_drivers/asgi.py +++ b/src/engineio/async_drivers/asgi.py @@ -59,12 +59,12 @@ async def __call__(self, scope, receive, send): else: static_file = get_static_file(scope['path'], self.static_files) \ if scope['type'] == 'http' and self.static_files else None - if static_file and os.path.exists(static_file['filename']): + if scope['type'] == 'lifespan': + await self.lifespan(receive, send) + elif static_file and os.path.exists(static_file['filename']): await self.serve_static_file(static_file, receive, send) elif self.other_asgi_app is not None: await self.other_asgi_app(scope, receive, send) - elif scope['type'] == 'lifespan': - await self.lifespan(receive, send) else: await self.not_found(receive, send)