Skip to content

fix: updated reboot logic#9073

Merged
zouyonghe merged 2 commits into
AstrBotDevs:masterfrom
CooperWang0912:fix/reboot-process
Jul 2, 2026
Merged

fix: updated reboot logic#9073
zouyonghe merged 2 commits into
AstrBotDevs:masterfrom
CooperWang0912:fix/reboot-process

Conversation

@CooperWang0912

@CooperWang0912 CooperWang0912 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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来实现在重启时打开新的终端来控制新进程

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

image

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.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.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:

  • Ensure reboot on Windows spawns a new console process so the new instance is properly attached and the original terminal can exit cleanly.

Tests:

  • Add unit test to verify that Windows reboot logic starts a new console process, exits the original process, and does not fall back to the POSIX exec path.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 29, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread astrbot/core/updator.py
Comment on lines +140 to +142
subprocess.Popen(
[executable] + argv[1:], creationflags=subprocess.CREATE_NEW_CONSOLE
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
subprocess.Popen(
[executable] + argv[1:], creationflags=subprocess.CREATE_NEW_CONSOLE
)
subprocess.Popen(
argv, creationflags=subprocess.CREATE_NEW_CONSOLE
)

@Soulter Soulter requested a review from zouyonghe June 30, 2026 12:53
@Soulter

Soulter commented Jun 30, 2026

Copy link
Copy Markdown
Member

@zouyonghe Does it affect compatibility with desktop users?

@zouyonghe

Copy link
Copy Markdown
Member

LGTM,短期风险较低可控,我后面会在桌面端补规避。

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 1, 2026
@zouyonghe

Copy link
Copy Markdown
Member

@sourcery-ai review

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@zouyonghe zouyonghe merged commit 3b41a87 into AstrBotDevs:master Jul 2, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants