1
0
mirror of https://github.com/hanxi/xiaomusic.git synced 2026-03-30 10:39:45 +08:00

fix: 修复退出异常问题

This commit is contained in:
涵曦
2024-07-28 08:48:39 +00:00
parent 49f727477e
commit 759130e38d

View File

@@ -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()