From 73ad03049b394fb16dad7815cc004efa4ce48eda Mon Sep 17 00:00:00 2001 From: anor Date: Thu, 26 Mar 2026 02:42:05 +1000 Subject: [PATCH] =?UTF-8?q?fix:=20fallback=20=D0=B5=D1=81=D0=BB=D0=B8=20Cl?= =?UTF-8?q?aude=20=D0=BD=D0=B5=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20result=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Проблема: Claude Code Docker иногда завершается без отправки result event в stream-json — UI зависал на "Claude анализирует..." Теперь после завершения процесса проверяем наличие файлов batch_script.py и batch_summary.json на диске. Co-Authored-By: Claude Opus 4.6 (1M context) --- batch_v2.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/batch_v2.py b/batch_v2.py index 5c89ad1..3c67f9f 100644 --- a/batch_v2.py +++ b/batch_v2.py @@ -367,13 +367,25 @@ async def run_claude_analysis( finally: if proc.returncode is None: proc.terminate() - await proc.wait() + await proc.wait() - # If Claude exited without result event — read stderr + # If Claude exited without emitting a result event — check files directly if not got_result: - stderr = await proc.stderr.read() - err_msg = stderr.decode()[:500] if stderr else "Claude exited without result" - yield {"type": "done", "script": "", "result": f"Error: {err_msg}"} + script_path = job_dir / "batch_script.py" + summary_path = job_dir / "batch_summary.json" + summary = {} + if summary_path.exists(): + try: + summary = json.loads(summary_path.read_text(encoding="utf-8")) + except (json.JSONDecodeError, OSError): + pass + if script_path.exists(): + script = script_path.read_text(encoding="utf-8") + yield {"type": "done", "script": script, "summary": summary} + else: + stderr = await proc.stderr.read() + err_msg = stderr.decode()[:500] if stderr else "Claude exited without generating script" + yield {"type": "done", "script": "", "result": f"Error: {err_msg}", "summary": summary} def run_batch_v2(job_id: str, script: str, source_dir: str, target_file: str):