From 79b31e883919746f4220390df527426870b06157 Mon Sep 17 00:00:00 2001 From: Poulpe Date: Tue, 21 Apr 2026 10:36:14 +0000 Subject: [PATCH] dispatcher : fix spin loop quand pas de worker dispo (sleep 30s) Co-Authored-By: Claude Sonnet 4.6 --- scripts/dispatcher.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/dispatcher.py b/scripts/dispatcher.py index df57dda..b52ff7a 100644 --- a/scripts/dispatcher.py +++ b/scripts/dispatcher.py @@ -293,12 +293,13 @@ def run_one_stitch(stitch: sqlite3.Row): finished_at=_now_iso()) -def run_one(job: sqlite3.Row): +def run_one(job: sqlite3.Row) -> bool: + """Returns True if a worker was picked and work started.""" job_id = job["id"] estimated = estimate_vram_mib(job["frame_count"] or 400) worker = pick_worker(estimated) if not worker: - return + return False set_status(job_id, status="extracting", worker_host=worker["host"], started_at=_now_iso()) try: frames_dir = do_extract(job, worker) @@ -311,6 +312,7 @@ def run_one(job: sqlite3.Row): _maybe_create_per_auv_stitch(job_id) except Exception as e: set_status(job_id, status="error", error=str(e)[:2000], finished_at=_now_iso()) + return True def pop_queued() -> sqlite3.Row | None: @@ -333,7 +335,9 @@ def main(): job = pop_queued() if job: print(f"→ job #{job['id']} ({job['auv']}/{job['gopro_serial']}/{job['segment_label']})") - run_one(job) + if not run_one(job): + print(" ↳ pas de worker dispo, retry dans 30s") + time.sleep(30) continue stitch = pop_queued_stitch() if stitch: