Merge branch 'dev' of https://github.com/MoFox-Studio/MoFox_Bot into dev
This commit is contained in:
@@ -33,9 +33,6 @@ class SchedulerDispatcher:
|
||||
# 追踪每个流的 schedule_id
|
||||
self.stream_schedules: dict[str, str] = {} # stream_id -> schedule_id
|
||||
|
||||
# 用于保护 schedule 创建/删除的锁,避免竞态条件
|
||||
self.schedule_locks: dict[str, asyncio.Lock] = {} # stream_id -> Lock
|
||||
|
||||
# Chatter 管理器
|
||||
self.chatter_manager: ChatterManager | None = None
|
||||
|
||||
@@ -85,12 +82,6 @@ class SchedulerDispatcher:
|
||||
self.chatter_manager = chatter_manager
|
||||
logger.debug(f"设置 Chatter 管理器: {chatter_manager.__class__.__name__}")
|
||||
|
||||
def _get_schedule_lock(self, stream_id: str) -> asyncio.Lock:
|
||||
"""获取流的 schedule 锁"""
|
||||
if stream_id not in self.schedule_locks:
|
||||
self.schedule_locks[stream_id] = asyncio.Lock()
|
||||
return self.schedule_locks[stream_id]
|
||||
|
||||
async def on_message_received(self, stream_id: str) -> None:
|
||||
"""消息接收时的处理逻辑
|
||||
|
||||
@@ -121,7 +112,7 @@ class SchedulerDispatcher:
|
||||
should_interrupt = await self._check_interruption(stream_id, context)
|
||||
|
||||
if should_interrupt:
|
||||
# 移除旧 schedule 并创建新的(内部有锁保护)
|
||||
# 移除旧 schedule 并创建新的
|
||||
await self._cancel_and_recreate_schedule(stream_id, context)
|
||||
logger.debug(f"⚡ 打断成功: 流={stream_id[:8]}..., 已重新创建 schedule")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user