fix: updated reboot logic#9073
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a Windows-specific reboot handling mechanism in astrbot/core/updator.py using subprocess.Popen. The feedback suggests simplifying the subprocess.Popen arguments by passing argv directly instead of redundantly slicing and concatenating the executable with argv[1:].
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| subprocess.Popen( | ||
| [executable] + argv[1:], creationflags=subprocess.CREATE_NEW_CONSOLE | ||
| ) |
There was a problem hiding this comment.
The expression [executable] + argv[1:] is redundant because argv is already constructed with executable as its first element (see _build_reboot_argv). You can pass argv directly to subprocess.Popen to simplify the code and avoid unnecessary list slicing and concatenation.
| subprocess.Popen( | |
| [executable] + argv[1:], creationflags=subprocess.CREATE_NEW_CONSOLE | |
| ) | |
| subprocess.Popen( | |
| argv, creationflags=subprocess.CREATE_NEW_CONSOLE | |
| ) |
|
@zouyonghe Does it affect compatibility with desktop users? |
|
LGTM,短期风险较低可控,我后面会在桌面端补规避。 |
|
@sourcery-ai review |
Issue / 问题
Running the program directly on Windows OS without using the CLI results in new process not being configured correctly in the original terminal. As a result, the user has to close the original terminal or manually find the new PID.
在Windows OS上不使用CLI直接运行程序会导致原先终端无法终止新进程,导致用户必须关闭原终端或寻找新的PID
See Issue 9064 for more details
详情请见 Issue 9064
Modifications / 改动点
Added new logic in updator to handle reboot when compiling directly on a Windows machine. By using subprocesses, the reboot process for compiling directly now opens a new window that maps correctly to the new process.
在updator中增加了在Windows OS上reboot的新逻辑,现在程序使用subprocess来实现在重启时打开新的终端来控制新进程
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Update reboot logic to correctly spawn a new console for AstrBot when running directly on Windows, and add tests to verify the new behavior.
Bug Fixes:
Tests: