This commit is contained in:
2026-03-06 13:23:32 +08:00
parent 4ba636e98c
commit afb2b78c15
29 changed files with 76 additions and 1521 deletions

View File

@@ -29,8 +29,11 @@ class AsyncEventBus:
tasks.append(asyncio.create_task(callback(**kwargs)))
if tasks:
await asyncio.gather(*tasks, return_exceptions=True)
logger.info(f"[EventBus] 事件 {event_type} 已成功广播给 {len(tasks)} 个订阅者")
results = await asyncio.gather(*tasks, return_exceptions=True)
for i, r in enumerate(results):
if isinstance(r, Exception):
logger.error(f"[EventBus] 事件 {event_type} 订阅者 {i} 异常: {r}")
logger.info(f"[EventBus] 事件 {event_type} 已广播给 {len(tasks)} 个订阅者")
# 全局单例,所有模块共用这一个广播台
bus = AsyncEventBus()