修复启动器退出时 _MEI 临时目录清理弹窗

This commit is contained in:
90CN committed 2026-11-05 23:33:52 +08:00
1 parent 1e936bfb84
commit b64de0f2a4
1 file changed
+13
+13
View File
@@ -381,6 +381,19 @@ def start_gmweb():
_logf("gmweb:%d 已在监听,跳过启动" % GM_WEB_PORT) _logf("gmweb:%d 已在监听,跳过启动" % GM_WEB_PORT)
return return
if getattr(sys, "frozen", False):
# A frozen onefile launcher must not spawn itself for gmweb: the
# child keeps the parent _MEI directory open after the window closes,
# which makes PyInstaller report "Failed to remove temporary directory".
_logf("gmweb: frozen mode uses in-process server")
start_gmweb_inproc(script)
for _ in range(30):
if port_open(GM_WEB_PORT):
_logf("gmweb: http://127.0.0.1:%d/ ready" % GM_WEB_PORT)
return
time.sleep(0.2)
return
try: try:
kwargs = {"cwd": os.path.dirname(script), kwargs = {"cwd": os.path.dirname(script),
"stdout": subprocess.DEVNULL, "stdout": subprocess.DEVNULL,