dispatcher : fix spin loop quand pas de worker dispo (sleep 30s)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Poulpe
2026-04-21 10:36:14 +00:00
parent 26e5bfc05b
commit 79b31e8839

View File

@@ -293,12 +293,13 @@ def run_one_stitch(stitch: sqlite3.Row):
finished_at=_now_iso()) 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"] job_id = job["id"]
estimated = estimate_vram_mib(job["frame_count"] or 400) estimated = estimate_vram_mib(job["frame_count"] or 400)
worker = pick_worker(estimated) worker = pick_worker(estimated)
if not worker: if not worker:
return return False
set_status(job_id, status="extracting", worker_host=worker["host"], started_at=_now_iso()) set_status(job_id, status="extracting", worker_host=worker["host"], started_at=_now_iso())
try: try:
frames_dir = do_extract(job, worker) frames_dir = do_extract(job, worker)
@@ -311,6 +312,7 @@ def run_one(job: sqlite3.Row):
_maybe_create_per_auv_stitch(job_id) _maybe_create_per_auv_stitch(job_id)
except Exception as e: except Exception as e:
set_status(job_id, status="error", error=str(e)[:2000], finished_at=_now_iso()) set_status(job_id, status="error", error=str(e)[:2000], finished_at=_now_iso())
return True
def pop_queued() -> sqlite3.Row | None: def pop_queued() -> sqlite3.Row | None:
@@ -333,7 +335,9 @@ def main():
job = pop_queued() job = pop_queued()
if job: if job:
print(f"→ job #{job['id']} ({job['auv']}/{job['gopro_serial']}/{job['segment_label']})") 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 continue
stitch = pop_queued_stitch() stitch = pop_queued_stitch()
if stitch: if stitch: