Skip to content

Commit 91d3db7

Browse files
committed
复了: 1. sys.stdout/sys.stderr 为 None — gui.py 开头重定向到 os.devnull,防止子进程 print()/tqdm 崩溃
1 parent 165a533 commit 91d3db7

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

backend/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ def vsf_output(out, ):
484484
Thread(target=count_process, daemon=True).start()
485485
# 已知BUG: test_chinese_cht.flv在net drive上会导致无法停止, 但在本地不会, 可能是vsf的原因
486486
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1,
487-
close_fds='posix' in sys.builtin_module_names, shell=False, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
487+
close_fds='posix' in sys.builtin_module_names, shell=False, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.CREATE_NO_WINDOW)
488488
ProcessManager.instance().add_process(p)
489489
self.manage_process(p.pid)
490490
p.wait()

gui.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99

1010
import sys
1111
import os
12+
13+
# PyInstaller --windowed 模式下 stdout/stderr 为 None,子进程 print/tqdm 会崩溃
14+
if sys.stdout is None:
15+
sys.stdout = open(os.devnull, 'w', encoding='utf-8')
16+
if sys.stderr is None:
17+
sys.stderr = open(os.devnull, 'w', encoding='utf-8')
18+
1219
import configparser
1320
import cv2
1421
import multiprocessing

0 commit comments

Comments
 (0)