Skip to content

fix(task): 补齐停止收尾确认 - #1891

Closed
jinghero wants to merge 3 commits into
AUTO-MAS-Project:devfrom
jinghero:fix/stop-cleanup-confirmation
Closed

jinghero wants to merge 3 commits into
AUTO-MAS-Project:devfrom
jinghero:fix/stop-cleanup-confirmation

Conversation

@jinghero

@jinghero jinghero commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

摘要

  • 在现有更新、配置保存确认之后补充限时执行收尾确认,再统一强制清理进程。
  • 修复手动停止时关闭模拟器、BetterGI 关闭游戏和账号后置脚本被拦截,导致结果保存中断及 MaaFW 项目持续占用的问题。
  • 保留重复取消等待、超时回收和未确认停写时的占用保护;分阶段确认不会重复执行已有检查。

关联 #1871。

验证

  • 同组回归在最新 dev 基线 c3f6c11b6 上 4 项失败,修复后通过;覆盖关闭命令、后置脚本、结果继续保存和同一项目再次取得预约。
  • Windows、Python 3.12.10、锁定依赖:全量测试 1740 passed、2 skipped、17 subtests passed;另补的无 Job 分支与 MaaFW 专项回归 3 passed。
  • Ruff 格式与静态检查、uv lock --check、更新日志碎片检查通过。
  • 使用隔离设备及系统命令替身,未执行真实游戏;复用现有任务运行与停止统计入口,无新增采集。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T10:39:35.550230Z 1b2fa8c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added 模块: 调度 按更新日志碎片自动设置 类型: 修复 按更新日志碎片自动设置 labels Nov 9, 2026

jinghero commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

总体结论:修改后合并

AUTO-MAS-Project/AUTO-MAS #1891

宝宝,这次把关闭模拟器、关闭游戏和后置脚本放回统一停止确认里,确实补上了原来“还没收尾就禁止启动清理命令”的缺口喵。不过根收尾提前启动后,原有的超时取消保护漏接了一处,停止仍可能一直等下去,先把这处补齐再合。

旧专项桥接器负责安排停止顺序,进程作用域负责确认期限与统一回收,各专项继续执行自己的收尾;不需要再造一套清理流程。

[逻辑 · P2] 根收尾提前启动后,超时不会取消它

位置:legacy.py:244–254、legacy.py:266–281、legacy.py:287–308。

静态追踪到的时序是:手动停止 → 更新确认通过 → execution_finalize 取消业务任务并等待完整收尾 → 根 finalizer 在作用域尚未关闭时登记。如果它等待的不是子进程,而是迟迟未返回的文件线程,10 秒后确认项虽然标记超时,却只取消了 shield 外面的等待任务。随后 force_close 回收子进程,统一取消又把 self._finalizer 留在 keep 中;外层再次取消业务任务也会被 TaskBase._wait_finalizer 的 shield 挡住。

这里有真实入口:MaaFW 托管收尾 在手动停止后仍会执行 audit_view 和日志备份清理的 to_thread 等待。文件 I/O 卡住时,进程强杀不会结束这些等待,停止操作就可能迟迟不能返回,任务也无法完成注销。此处不是声称实际复现。

原先根 final_task 先等停止检查结束,再登记收尾,此时 scope.closed 为真,watch_finalizer 会挂上有限取消计时器;现在登记提前了,而关闭作用域时没有给已登记的根收尾补上这层保护。

建议由旧专项停止编排补齐根 finalizer 的到期取消,或复用 scope 中已有登记在强清理时处理它,保留正常收尾的宽限和真实未完成工作原有的占用保护。验收再补一个“根收尾等待文件线程、没有子进程可杀”的场景:到期后停止能够返回,不能只靠杀掉进程让等待自然结束。现有超时回归等的是进程退出,覆盖不到这一支,猫爪子就按在这里啦。

本轮为静态源码与调用链审查,没有执行项目代码或测试。已核对新增回归的断言与既有停止保护;CI 状态以当前检查页为准,作者的本机验证不作为本轮独立执行结果。

—— dot酱敬上 🐾

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b2fa8cf6f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/task/legacy.py
Comment on lines +250 to +254
"execution_finalize",
self._confirm_execution_stop,
timeout=self.owner.STOP_CHECK_TIMEOUTS["finalize"],
)
await scope.run_checks()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Retain project reservations until native shutdown is confirmed

When a MaaFW pretask refuses termination and the no-Job fallback kill also fails, this new phase releases the project reservation prematurely. _kill_pretask_process() logs and swallows termination errors, so MaaFWPluginAutoProxyTask._finalize_user() can continue to _release_project_path() despite the surviving process. Running that finalizer before scope.force_close() means cleanup_failed is recorded only after the reservation has been released, allowing another run or update to access the same project while the old pretask is still writing. Preserve the reservation until process termination is actually confirmed, including when unified cleanup fails.

Useful? React with 👍 / 👎.

@jinghero jinghero closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

模块: 调度 按更新日志碎片自动设置 类型: 修复 按更新日志碎片自动设置

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant