From a4bf2ee5a67292584ddbbcb60a492cf4e6ecac68 Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Mon, 19 Jan 2026 23:52:05 +0000 Subject: [PATCH] fix: prevent blocking on shutdown in sync executionEnsure the orchestrator does not stall on hung requests by allowing the ThreadPoolExecutor to shut down without waiting for ongoing tasks to complete. Also, add a condition to skip validation for specific JSON files in the repair function. --- scripts/component_migration_orchestrator.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/component_migration_orchestrator.py b/scripts/component_migration_orchestrator.py index d467c22..f4ae502 100644 --- a/scripts/component_migration_orchestrator.py +++ b/scripts/component_migration_orchestrator.py @@ -508,9 +508,13 @@ def _is_connection_error(exc: Exception) -> bool: def _run_sync_with_timeout(agent: Agent, prompt: str, timeout: float) -> Any: - with ThreadPoolExecutor(max_workers=1) as executor: - future = executor.submit(Runner.run_sync, agent, prompt) + executor = ThreadPoolExecutor(max_workers=1) + future = executor.submit(Runner.run_sync, agent, prompt) + try: return future.result(timeout=timeout) + finally: + # Do not block on shutdown; a hung request should not stall the orchestrator. + executor.shutdown(wait=False, cancel_futures=True) def _run_with_retries(agent: Agent, prompt: str, label: str) -> Any: @@ -760,6 +764,8 @@ def _coerce_content_output(output: str, path: str, label: str, debug: bool) -> s def _validate_and_repair_json_file(path: Path, label: str, debug: bool) -> None: if not path.exists(): return + if path.name == "json-components-registry.json" and label.startswith("diff-json:"): + return try: json.loads(path.read_text(encoding="utf-8")) except json.JSONDecodeError as exc: