From de68a6a8ee52e1757572177a6b5375dd0fb276ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E7=8C=AB?= Date: Thu, 1 May 2025 14:34:59 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=94=B9=20MessageManager=20?= =?UTF-8?q?=E7=9A=84=E5=B1=9E=E6=80=A7=E6=A3=80=E6=9F=A5=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E4=BB=A5=E9=98=B2=E6=AD=A2=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/plugins/chat/message_sender.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/chat/message_sender.py b/src/plugins/chat/message_sender.py index fdeec346e..0f8605512 100644 --- a/src/plugins/chat/message_sender.py +++ b/src/plugins/chat/message_sender.py @@ -146,6 +146,7 @@ class MessageManager: """管理所有聊天流的消息容器 (不再是单例)""" def __init__(self): + self._processor_task = None self.containers: dict[str, MessageContainer] = {} self.storage = MessageStorage() # 添加 storage 实例 self._running = True # 处理器运行状态 @@ -155,7 +156,7 @@ class MessageManager: async def start(self): """启动后台处理器任务。""" # 检查是否已有任务在运行,避免重复启动 - if hasattr(self, "_processor_task") and not self._processor_task.done(): + if self._processor_task is not None and not self._processor_task.done(): logger.warning("Processor task already running.") return self._processor_task = asyncio.create_task(self._start_processor_loop()) @@ -164,7 +165,7 @@ class MessageManager: def stop(self): """停止后台处理器任务。""" self._running = False - if hasattr(self, "_processor_task") and not self._processor_task.done(): + if self._processor_task is not None and not self._processor_task.done(): self._processor_task.cancel() logger.debug("MessageManager processor task stopping.") else: