mirror of
https://github.com/zhouxiaoka/autoclip.git
synced 2026-09-03 06:24:14 +08:00
Once the pipeline actually executes locally (previous commit), the multiple dispatch entry points became a real hazard: clicking retry fires /retry while the frontend's auto-start fires /process for the now-pending project, so two process_video_pipeline runs start ~1s apart and race on the same DB Task row: "Instance '<Task ...>' has been deleted, or its row is otherwise not present". Add an in-process concurrency guard: a module-level set of active project_ids behind a lock. process_video_pipeline skips immediately if the project already has a pipeline running, and releases the slot in the inner finally (plus a belt-and-suspenders release in the outer except for very-early failures). Verified: a single retry runs exactly one pipeline (Step 1 executes); firing /retry and /process back-to-back yields zero "has been deleted" DB races. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>