From 302f79b6f41291c5dc181e88bfcb3d9a13fc88f6 Mon Sep 17 00:00:00 2001 From: SolitaryThinker Date: Fri, 10 Jul 2026 19:40:31 -0700 Subject: [PATCH] [bugfix]: park the in-flight job back in _pending if the scheduler loop crashes (#1453) If _run dies between popping a job off the queue and resolving its future, that job belonged to neither _queue nor _pending, so the crash drain could not fail it and its submitter hung forever. Re-park it in _pending on the way out so _on_run_done fails it like everything else. --- fastvideo/entrypoints/openai/batching.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fastvideo/entrypoints/openai/batching.py b/fastvideo/entrypoints/openai/batching.py index 9a3a3fe9d..79f53cc5a 100644 --- a/fastvideo/entrypoints/openai/batching.py +++ b/fastvideo/entrypoints/openai/batching.py @@ -101,8 +101,15 @@ class VideoBatchScheduler: job = await self._get_next_job() if job is None: break - batch = await self._collect_batch(job) - await self._dispatch(batch) + try: + batch = await self._collect_batch(job) + await self._dispatch(batch) + except BaseException: + # The job was already popped off the queue; park it back in + # _pending so the crash drain in _on_run_done fails its future + # instead of leaving it hanging forever. + self._pending.append(job) + raise # Fail jobs stranded in _pending AND still sitting in _queue (e.g. # submitted while the final dispatch was in flight when stop() landed).