fix(maafw): 只关自己开起来的模拟器 - #632
Closed
qiyinxi wants to merge 2 commits into
Closed
Conversation
`opened_emulator` 原来在调 `open()` 前无条件置真,收尾的 `_close_emulator()` 只看这个 标记——于是用户自己开着的模拟器,跑完一轮任务就被 MAS 关掉了。模拟器开关在 Windows 上还要过 UAC,被误关一次的代价不只是「再开一次」。 改成先查一次 `getStatus()`:已经 ONLINE 就只连接、不接管生命周期;查状态本身失败时按 「不是我开的」处理——宁可少关一次,也不误关别人的。日志也跟着分开,本来就开着时不再 误报「正在启动模拟器」。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
审查者指南(小型 PR 中折叠显示)审查者指南MFW 启动模拟器前先查询其在线状态:已运行的实例仅连接、不接管生命周期;只有确认原先未运行时才标记为 AUTO-MAS 启动并在任务结束时关闭,查询失败则采取保守策略避免误关用户实例。 MFW 模拟器所有权与清理流程图sequenceDiagram
participant RunnerTask
participant EmulatorManager
participant Emulator
RunnerTask->>EmulatorManager: getStatus(emulator_index)
alt status is DeviceStatus.ONLINE
EmulatorManager-->>RunnerTask: DeviceStatus.ONLINE
RunnerTask->>RunnerTask: opened_emulator = False
RunnerTask->>EmulatorManager: open(emulator_index)
EmulatorManager->>Emulator: connect
else status is not ONLINE or query fails
EmulatorManager-->>RunnerTask: unavailable or other status
RunnerTask->>RunnerTask: opened_emulator = True
RunnerTask->>EmulatorManager: open(emulator_index)
EmulatorManager->>Emulator: start and connect
end
RunnerTask-->>Emulator: close only when opened_emulator is True
文件级变更
提示与命令与 Sourcery 交互
自定义你的体验访问你的控制面板即可:
获取帮助Original review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideMFW 启动模拟器前先查询其在线状态:已运行的实例仅连接、不接管生命周期;只有确认原先未运行时才标记为 AUTO-MAS 启动并在任务结束时关闭,查询失败则采取保守策略避免误关用户实例。 Sequence diagram for MFW emulator ownership and cleanupsequenceDiagram
participant RunnerTask
participant EmulatorManager
participant Emulator
RunnerTask->>EmulatorManager: getStatus(emulator_index)
alt status is DeviceStatus.ONLINE
EmulatorManager-->>RunnerTask: DeviceStatus.ONLINE
RunnerTask->>RunnerTask: opened_emulator = False
RunnerTask->>EmulatorManager: open(emulator_index)
EmulatorManager->>Emulator: connect
else status is not ONLINE or query fails
EmulatorManager-->>RunnerTask: unavailable or other status
RunnerTask->>RunnerTask: opened_emulator = True
RunnerTask->>EmulatorManager: open(emulator_index)
EmulatorManager->>Emulator: start and connect
end
RunnerTask-->>Emulator: close only when opened_emulator is True
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
Author
|
误提,撤回。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MFW 内置运行无条件把
opened_emulator置为 True,收尾时连用户自己开着的模拟器一起关掉。改成先查状态:
getStatus() == ONLINE说明本来就在跑,只连接、不接管生命周期;查询失败按「不是我开的」处理,宁可少关一次。app/task/MaaFW/tools/embedded/runner_task.py,+16/-3。本地:
pytest tests -q710 passed / 3 skipped,--collect-only退出码 0。🤖 Generated with Claude Code
Sourcery 摘要
在继续管理由 AUTO-MAS 启动的实例的同时,保留用户启动的模拟器的生命周期。
错误修复:
Original summary in English
Summary by Sourcery
Preserve the lifecycle of user-started emulators while continuing to manage instances launched by AUTO-MAS.
Bug Fixes: