From 759130e38d5e7fe79928f687ff76842a367f3ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Sun, 28 Jul 2024 08:48:39 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=80=80=E5=87=BA?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaomusic/httpserver.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xiaomusic/httpserver.py b/xiaomusic/httpserver.py index 9019f5f..870a25f 100644 --- a/xiaomusic/httpserver.py +++ b/xiaomusic/httpserver.py @@ -29,9 +29,11 @@ log = None @asynccontextmanager async def app_lifespan(app): if xiaomusic is not None: - task = asyncio.create_task(xiaomusic.run_forever()) - yield - task.cancel() + asyncio.create_task(xiaomusic.run_forever()) + try: + yield + except Exception as e: + log.exception(f"Execption {e}") security = HTTPBasic()