win-ci: 조사 4 (변환 멈춤 스택 앞부분, scipy 를 주 스레드에서 먼저 불러오면 낫는지)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-15 03:31:33 +09:00
parent e7604206bb
commit c1b0d2a5c9
2 changed files with 52 additions and 45 deletions

View File

@@ -72,7 +72,7 @@ try {
if ($Phase -eq 'debug') {
# 원인 조사용: worker/scripts/win_debug.py 만 돌린다 (venv 는 이전 실행 것을 그대로 씀)
$r['debug'] = Step 'debug' {
& $py -X faulthandler worker\scripts\win_debug.py
& $py -X faulthandler worker\scripts\win_debug.py protocol
"exit $LASTEXITCODE"
}
$sum = Join-Path $OutDir 'summary.log'

View File

@@ -36,7 +36,7 @@ CASES = {
"ct2_first_full": "import ctranslate2; p('ct2 loaded')\nCT=0; VF=True; WT=True\n",
}
env = {**os.environ, "PYTHONUTF8": "1", "PYTHONIOENCODING": "utf-8"}
for name, head in CASES.items():
for name, head in (CASES.items() if 'protocol' not in sys.argv else []):
code = PRE + head + STEPS
try:
p = subprocess.run([sys.executable, "-c", code], capture_output=True, text=True, encoding="utf-8",
@@ -57,50 +57,57 @@ import queue
import tempfile
import threading
data = tempfile.mkdtemp(prefix="gvr-dbg-")
dump = os.path.join(data, "stack.txt")
boot = ("import faulthandler, os, runpy, sys\n"
"f = open(os.environ['GVR_DUMP'], 'w')\n"
"faulthandler.dump_traceback_later(200, exit=True, file=f)\n"
"sys.argv = ['gvr_worker']\n"
"runpy.run_module('gvr_worker', run_name='__main__')\n")
wp = subprocess.Popen([sys.executable, "-c", boot], cwd=WORKER, env={**env, "GVR_DATA_DIR": data, "GVR_DUMP": dump},
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, encoding="utf-8")
q: "queue.Queue[str]" = queue.Queue()
errs: list = []
threading.Thread(target=lambda: [q.put(l) for l in wp.stdout], daemon=True).start()
threading.Thread(target=lambda: [errs.append(l.rstrip()) for l in wp.stderr], daemon=True).start()
def run_protocol(name, pre=''):
print(f"===== protocol {name}", flush=True)
data = tempfile.mkdtemp(prefix="gvr-dbg-")
dump = os.path.join(data, "stack.txt")
boot = (pre + "import faulthandler, os, runpy, sys\n"
"f = open(os.environ['GVR_DUMP'], 'w')\n"
"faulthandler.dump_traceback_later(200, exit=True, file=f)\n"
"sys.argv = ['gvr_worker']\n"
"runpy.run_module('gvr_worker', run_name='__main__')\n")
wp = subprocess.Popen([sys.executable, "-c", boot], cwd=WORKER, env={**env, "GVR_DATA_DIR": data, "GVR_DUMP": dump},
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, encoding="utf-8")
q: "queue.Queue[str]" = queue.Queue()
errs: list = []
threading.Thread(target=lambda: [q.put(l) for l in wp.stdout], daemon=True).start()
threading.Thread(target=lambda: [errs.append(l.rstrip()) for l in wp.stderr], daemon=True).start()
def req(rid, op, timeout, **kw):
wp.stdin.write(json.dumps({"id": rid, "op": op, **kw}, ensure_ascii=False) + "\n")
wp.stdin.flush()
while True:
line = q.get(timeout=timeout)
msg = json.loads(line)
if msg.get("id") == rid and "event" not in msg:
return msg
def req(rid, op, timeout, **kw):
wp.stdin.write(json.dumps({"id": rid, "op": op, **kw}, ensure_ascii=False) + "\n")
wp.stdin.flush()
while True:
line = q.get(timeout=timeout)
msg = json.loads(line)
if msg.get("id") == rid and "event" not in msg:
return msg
print("===== protocol", flush=True)
try:
for rid, op, to, kw in [
("1", "download", 900, {"target": "model", "name": "tiny"}),
("2", "load", 300, {"slot": "realtime", "model": "tiny", "device": "cpu", "compute_type": "int8"}),
("3", "transcribe", 260, {"slot": "realtime", "path": OGG, "hotwords": "", "corrections": [], "dictionary": [],
"target_lufs": -18, "noise_sensitivity": 0.5, "denoise": False, "profile_lufs": None}),
]:
r = req(rid, op, to, **kw)
print(op, json.dumps(r, ensure_ascii=False)[:400], flush=True)
except queue.Empty:
print("응답 없음 (멈춤)", flush=True)
wp.stdin.close()
try:
wp.wait(timeout=30)
except subprocess.TimeoutExpired:
wp.kill()
wp.wait()
print("worker exit", wp.returncode, flush=True)
print("--- stderr tail\n" + "\n".join(errs[-30:]), flush=True)
if os.path.exists(dump):
print("--- stack dump\n" + open(dump, encoding="utf-8", errors="replace").read()[-6000:], flush=True)
try:
for rid, op, to, kw in [
("1", "download", 900, {"target": "model", "name": "tiny"}),
("2", "load", 300, {"slot": "realtime", "model": "tiny", "device": "cpu", "compute_type": "int8"}),
("3", "transcribe", 260, {"slot": "realtime", "path": OGG, "hotwords": "", "corrections": [], "dictionary": [],
"target_lufs": -18, "noise_sensitivity": 0.5, "denoise": False, "profile_lufs": None}),
]:
r = req(rid, op, to, **kw)
print(op, json.dumps(r, ensure_ascii=False)[:400], flush=True)
except queue.Empty:
print("응답 없음 (멈춤)", flush=True)
wp.stdin.close()
try:
wp.wait(timeout=30)
except subprocess.TimeoutExpired:
wp.kill()
wp.wait()
print("worker exit", wp.returncode, flush=True)
print("--- stderr tail\n" + "\n".join(errs[-30:]), flush=True)
if os.path.exists(dump):
st = open(dump, encoding="utf-8", errors="replace").read()
print("--- stack dump (앞)\n" + st[:5000], flush=True)
print("--- stack dump (뒤)\n" + st[-2500:], flush=True)
run_protocol('as-is')
run_protocol('scipy-main-thread', 'import pyloudnorm, scipy.signal\n')