[Bugfix] Keep async video jobs queued until inference and abort on delete (#6759)

Signed-off-by: ZhengWG <zwg0606@gmail.com>
Signed-off-by: wuli666 <421774554@qq.com>
Co-authored-by: wuli666 <421774554@qq.com>
This commit is contained in:
Zheng Wengangandwuli666 authored and GitHub committed 2026-09-15 20:43:30 -07:00
1 parent 5dbae2b182
commit 275720b378
22 files changed
+549 -44

No files matched your search

+26 -6
View File
@@ -86,7 +86,7 @@ from vllm.v1.engine.exceptions import EngineDeadError, EngineGenerateError
from vllm_omni.config.endpoint_policy import (
shutdown_unsupported_routes,
)
from vllm_omni.entrypoints.async_omni import AsyncOmni
from vllm_omni.entrypoints.async_omni import ABORT_TIMEOUT_S, AsyncOmni
from vllm_omni.entrypoints.duplex.capability import should_enable_duplex_endpoint
from vllm_omni.entrypoints.duplex.serving import OmniDuplexSessionHandler
from vllm_omni.entrypoints.duplex.warmup import _warmup_duplex_realtime
@@ -201,6 +201,8 @@ from vllm_omni.utils.tracking_parser import TrackingArgumentParser, TrackingName
logger = init_logger(__name__)
router = APIRouter()
VIDEO_ABORT_TIMEOUT_S = ABORT_TIMEOUT_S
profiler_router = APIRouter()
@@ -2518,11 +2520,11 @@ async def retrieve_video(video_id: str) -> VideoResponse | JSONResponse:
@router.delete("/v1/videos/{video_id}")
async def delete_video(video_id: str) -> VideoDeleteResponse:
async def delete_video(video_id: str, raw_request: Request) -> VideoDeleteResponse:
"""Delete a stored video job and any generated output.
If the job is still queued or running, this endpoint first attempts to
cancel the in-flight generation task before removing the stored metadata.
In-flight jobs get a bounded engine abort, then frontend cancel. The job
is re-read afterwards so a completed save is not orphaned.
Args:
video_id: Identifier of the video job to delete.
@@ -2539,19 +2541,37 @@ async def delete_video(video_id: str) -> VideoDeleteResponse:
raise HTTPException(status_code=404, detail="Video not found")
if job.status in (VideoGenerationStatus.QUEUED, VideoGenerationStatus.IN_PROGRESS):
handler = raw_request.app.state.openai_serving_video
try:
await asyncio.wait_for(handler.abort_request(video_id), timeout=VIDEO_ABORT_TIMEOUT_S)
except asyncio.TimeoutError:
logger.warning(
"Timed out aborting video request %s after %.1fs; "
"engine abort is best-effort until the current batch drains",
video_id,
VIDEO_ABORT_TIMEOUT_S,
)
except Exception:
logger.exception("Failed to abort in-flight video request %s", video_id)
task = await VIDEO_TASKS.get(video_id)
if task is not None:
task.cancel()
try:
await asyncio.wait_for(task, timeout=2.0)
# Cancel cleanup may spend a full abort budget; +2s covers scheduling slack.
await asyncio.wait_for(task, timeout=VIDEO_ABORT_TIMEOUT_S + 2.0)
except asyncio.TimeoutError:
raise HTTPException(status_code=409, detail="Cancellation in progress. Please try again later.")
except asyncio.CancelledError:
pass
job = await VIDEO_STORE.get(video_id)
if job is None:
return VideoDeleteResponse(id=video_id, deleted=True)
if job.status in (VideoGenerationStatus.QUEUED, VideoGenerationStatus.IN_PROGRESS):
await VIDEO_STORE.pop(video_id)
return VideoDeleteResponse(id=job.id, deleted=True)
elif job.status is VideoGenerationStatus.FAILED:
if job.status is VideoGenerationStatus.FAILED:
if job.file_name is not None:
try:
await STORAGE_MANAGER.delete(video_id)