From c3eaee77d3f751a2ffcef8bedc867ecadea66494 Mon Sep 17 00:00:00 2001 From: abersheeran Date: Wed, 26 Jun 2024 17:49:43 +0800 Subject: [PATCH] fix ASGI app running error message set --- a2wsgi/asgi.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/a2wsgi/asgi.py b/a2wsgi/asgi.py index 90790ca..2c52bad 100644 --- a/a2wsgi/asgi.py +++ b/a2wsgi/asgi.py @@ -182,15 +182,18 @@ def asgi_done_callback(self, future: asyncio.Future) -> None: pass else: if exception is not None: - self.sync_event.set( - { - "type": "a2wsgi.error", - "exception": ( - type(exception), - exception, - exception.__traceback__, - ), - } + task = asyncio.create_task(self.sync_event_set_lock.acquire()) + task.add_done_callback( + lambda _: self.sync_event.set( + { + "type": "a2wsgi.error", + "exception": ( + type(exception), + exception, + exception.__traceback__, + ), + } + ) ) finally: self.asgi_done.set()