Files
Pier_v1/Code/교각모델링앱/tools/test_runner_stall.py
T
ahnyongjooandClaude Sonnet 5.5 964a841de1 chore(rebar): Pier_T_rebar 작업 폴더 초기 구성 및 외부 의존 파일 통합
- Code\rebar_pipeline, review_pipeline, pier-program을 정션에서 실제 폴더로 전환
- Code\rhino_mcp 및 CLAUDE_rhino배경.md 추가, .mcp.json은 PYTHONPATH로 새 위치 사용
- pier-program 내부 .git 제거(이력은 backup\pier-program_20261028.bundle에 보관)
- worktree 가이드 반영(CLAUDE.local.md, HANDOFF.md)
- D:\Rhino-MCP 경로 참조를 새 위치로 치환

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 11:20:18 +09:00

47 lines
1.9 KiB
Python

"""Runner stall handling check (2026-10-12).
1. start_timeout=3 s with 1 retry: Rhino cannot start a script that fast -> both attempts are killed, RhinoJobError
lists 2 attempts with the window title, and no Rhino process from this test is left running.
2. normal run: result returned and no Rhino left behind (exit mode exited / killed after result is recorded).
"""
import subprocess
import sys
import tempfile
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from runner import RhinoJobError, run_job # noqa: E402
step = Path(tempfile.mkdtemp()) / "noop.py"
step.write_text("print('noop')\n", encoding="utf-8")
def rhino_count():
out = subprocess.run(["tasklist", "/FI", "IMAGENAME eq Rhino.exe", "/FO", "CSV", "/NH"], capture_output=True, text=True)
return out.stdout.count("Rhino.exe")
ok = True
before = rhino_count()
try:
run_job([{"name": "noop", "script": step}], start_timeout=3, retries=1)
print("FAIL stall: no error raised")
ok = False
except RhinoJobError as e:
n = str(e).count("did not start the job within 3s")
print("PASS" if n == 2 else "FAIL", "stall: attempts reported", n, "|", str(e)[:200])
ok &= n == 2
left = rhino_count() - before
print("PASS" if left == 0 else "FAIL", "stall: Rhino processes left", left)
ok &= left == 0
r = run_job([{"name": "noop", "script": step}])
good = r["ok"] and r["steps"][0]["stdout"].strip() == "noop"
print("PASS" if good else "FAIL", "normal run returns the result:", r["wall_secs"], "s")
# How Rhino ended is recorded, not judged: since 2026-10-12 13:00 Rhino on this PC often stays alive after
# _-Exit (cause not identified); the runner then kills it after the grace period, the result is already safe.
print("INFO rhino exit:", r["rhino_exit"])
left = rhino_count() - before
print("PASS" if left == 0 else "FAIL", "normal run: Rhino processes left", left)
ok &= good and left == 0
sys.exit(0 if ok else 1)