From d8eb3d386965c5a0576d31c38f30e06a63b31afe Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Wed, 29 Apr 2026 04:35:06 +0800 Subject: [PATCH] fix: dashboard_shutdown_event None safety, missing KnowledgeBaseUploadError import, core_lifecycle imports and type errors --- astrbot/core/core_lifecycle.py | 17 ++++++++--------- astrbot/core/initial_loader.py | 3 +++ astrbot/core/knowledge_base/kb_helper.py | 1 + 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/astrbot/core/core_lifecycle.py b/astrbot/core/core_lifecycle.py index 9a4ba1320..5f105010f 100644 --- a/astrbot/core/core_lifecycle.py +++ b/astrbot/core/core_lifecycle.py @@ -17,14 +17,6 @@ import traceback from asyncio import Queue from enum import Enum - -class LifecycleState(Enum): - CREATED = "created" - CORE_READY = "core_ready" - RUNTIME_READY = "runtime_ready" - RUNTIME_FAILED = "runtime_failed" - - from astrbot.api import logger, sp from astrbot.core import LogBroker, LogManager from astrbot.core.astrbot_config_mgr import AstrBotConfigManager @@ -52,6 +44,13 @@ from . import astrbot_config, html_renderer from .event_bus import EventBus +class LifecycleState(Enum): + CREATED = "created" + CORE_READY = "core_ready" + RUNTIME_READY = "runtime_ready" + RUNTIME_FAILED = "runtime_failed" + + class AstrBotCoreLifecycle: """AstrBot 核心生命周期管理类, 负责管理 AstrBot 的启动、停止、重启等操作. @@ -526,7 +525,7 @@ class AstrBotCoreLifecycle: self.start_time = int(time.time()) # 初始化当前任务列表 - self.curr_tasks: list[asyncio.Task] = [] + self.curr_tasks = [] # 根据配置实例化各个平台适配器 await self.platform_manager.initialize() diff --git a/astrbot/core/initial_loader.py b/astrbot/core/initial_loader.py index 3f836a4c4..942a060e2 100644 --- a/astrbot/core/initial_loader.py +++ b/astrbot/core/initial_loader.py @@ -37,6 +37,9 @@ class InitialLoader: webui_dir = self.webui_dir + assert core_lifecycle.dashboard_shutdown_event is not None, ( + "dashboard_shutdown_event was not initialized" + ) self.dashboard_server = AstrBotDashboard( core_lifecycle, self.db, diff --git a/astrbot/core/knowledge_base/kb_helper.py b/astrbot/core/knowledge_base/kb_helper.py index 70ddcaeed..5fb88c3e1 100644 --- a/astrbot/core/knowledge_base/kb_helper.py +++ b/astrbot/core/knowledge_base/kb_helper.py @@ -9,6 +9,7 @@ import aiofiles from astrbot.core import logger from astrbot.core.db.vec_db.faiss_impl.vec_db import FaissVecDB +from astrbot.core.exceptions import KnowledgeBaseUploadError from astrbot.core.provider.manager import ProviderManager from astrbot.core.provider.provider import ( EmbeddingProvider,