diff --git a/scripts/dispatcher.py b/scripts/dispatcher.py index f740c46..c42e3c2 100644 --- a/scripts/dispatcher.py +++ b/scripts/dispatcher.py @@ -209,7 +209,9 @@ def do_extract(job: sqlite3.Row, worker: dict) -> str: ssh(worker["ssh_alias"], f"setsid bash -c {shlex.quote(bg)} >/dev/null 2>&1 &") while True: - rc_done, _, _ = ssh(worker["ssh_alias"], f"test -f {shlex.quote(exit_file)}") + # Use -s (file exists AND size > 0) to avoid race: setsid bash writes the exit code + # AFTER ffmpeg finishes; a plain -f can match a zero-byte placeholder mid-write. + rc_done, _, _ = ssh(worker["ssh_alias"], f"test -s {shlex.quote(exit_file)}") current = count_frames(worker, frames_dir) pct = min(99, current * 100 // total_frames_est) set_status(job["id"], frame_count=current, progress=pct)