[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.
This commit is contained in:
SolitaryThinker
2026-07-11 18:35:45 -07:00
parent efc53ba93b
commit 302f79b6f4
+9 -2
View File
@@ -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).