dispatcher — fix race condition sur exit_file extract

Le setsid bash lance ffmpeg puis ecrit le code de retour:
  echo $? > exit_file

Avec test -f on matchait le fichier pendant que le shell le creait vide
(write() du "> exit_file" cree le fichier avant fwrite). Resultat:
code_str="" -> isdigit()=False -> rc=1 -> ffmpeg failed false positive.

Fix: test -s (existe ET non-vide) pour attendre que echo ait termine.
This commit is contained in:
Flag
2026-04-22 09:35:48 +00:00
parent 621f4e63e8
commit 2599a376af

View File

@@ -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)