Skip to content

fix: 修复 EventsManager 任务清理时 Key 不一致#1518

Open
KeepingRunning wants to merge 1 commit intoMai-with-u:devfrom
KeepingRunning:fix-key
Open

fix: 修复 EventsManager 任务清理时 Key 不一致#1518
KeepingRunning wants to merge 1 commit intoMai-with-u:devfrom
KeepingRunning:fix-key

Conversation

@KeepingRunning
Copy link
Contributor

@KeepingRunning KeepingRunning commented Feb 19, 2026

  • ✅ 接受:与main直接相关的Bug修复:提交到dev分支
  • 新增功能类pr需要经过issue提前讨论,否则不会被合并

请填写以下内容

(删除掉中括号内的空格,并替换为小写的x

    • main 分支 禁止修改,请确认本次提交的分支 不是 main 分支
    • 我确认我阅读了贡献指南
    • 本次更新类型为:BUG修复
    • 本次更新类型为:功能新增
    • 本次更新是否经过测试
  1. 请填写破坏性更新的具体内容(如有):无
  2. 请简要说明本次更新的内容和目的:
    修复 EventsManager 中异步任务清理逻辑 Key 值不一致导致的 KeyError 问题。

问题现象:原代码在 _dispatch_handler_task 中使用 handler_name 作为 key 存储任务,但在 _task_done_callback 中却尝试使用 task.get_name()(包含 plugin 前缀)作为 key 移除任务,导致回调执行时任务无法被正常清理。

修复方案:通过闭包将确定的 handler_name 传递给回调函数,确保插入和删除使用的 key 完全一致。

优化:在回调中增加了对空任务列表的自动删除逻辑,避免 _handler_tasks 字典无效膨胀。

其他信息

  • 关联 Issue:Close #
  • 截图/GIF
  • 附加信息:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant