fix: dispose database engine on shutdown (#8650)

This commit is contained in:
時壹
2026-06-08 12:00:26 +09:00
committed by GitHub
parent af70151ff8
commit 4b562689ee

View File

@@ -391,6 +391,12 @@ class AstrBotCoreLifecycle:
except Exception as e:
logger.error(f"任务 {task.get_name()} 发生错误: {e}")
# 释放数据库引擎连接池
try:
await self.db.engine.dispose()
except Exception as e:
logger.warning(f"释放数据库引擎失败: {e}")
async def restart(self) -> None:
"""重启 AstrBot 核心生命周期管理类, 终止各个管理器并重新加载平台实例"""
await self.provider_manager.terminate()