新增思维流

This commit is contained in:
SengokuCola
2025-03-23 17:47:17 +08:00
parent c635c9f185
commit 9f87cab148
9 changed files with 402 additions and 9 deletions

2
bot.py
View File

@@ -139,10 +139,12 @@ async def graceful_shutdown():
uvicorn_server.force_exit = True # 强制退出
await uvicorn_server.shutdown()
logger.info("正在关闭所有任务...")
tasks = [t for t in asyncio.all_tasks() if t is not asyncio.current_task()]
for task in tasks:
task.cancel()
await asyncio.gather(*tasks, return_exceptions=True)
logger.info("所有任务已关闭")
except Exception as e:
logger.error(f"麦麦关闭失败: {e}")