serving_engine ¶
Shared asynchronous execution substrate for OpenAI-compatible routes.
Classes¶
fastvideo.entrypoints.openai.serving_engine.OpenAIServingEngine ¶
OpenAIServingEngine(generator: ServingGenerator, video_request_validator: Callable[[VideoGenerationRequest], None] | None = None)
Own generator lifecycle and serialize access to its mutable pipeline.
FastVideo pipelines contain request-mutated sampling state and some LoRA implementations merge weights in place. Running two Python threads through one pipeline is therefore unsafe even if the HTTP layer accepts requests concurrently. This engine gives every OpenAI route one model-agnostic async entrypoint while preserving that invariant. A future scheduler can replace the lock without changing the transport contract.
Source code in fastvideo/entrypoints/openai/serving_engine.py
Methods:¶
fastvideo.entrypoints.openai.serving_engine.OpenAIServingEngine.generate async ¶
generate(request: GenerationRequest, *, on_start: Callable[[], Awaitable[None]] | None = None) -> Any
Generate one typed request without blocking the event loop.
Source code in fastvideo/entrypoints/openai/serving_engine.py
fastvideo.entrypoints.openai.serving_engine.OpenAIServingEngine.run_async_serialized async ¶
Run an async operation under the same pipeline lock.
Source code in fastvideo/entrypoints/openai/serving_engine.py
fastvideo.entrypoints.openai.serving_engine.OpenAIServingEngine.run_serialized async ¶
run_serialized(function: Callable[..., _T], *args: Any, on_start: Callable[[], Awaitable[None]] | None = None, **kwargs: Any) -> _T
Run a synchronous pipeline operation under the serving lock.
Source code in fastvideo/entrypoints/openai/serving_engine.py
fastvideo.entrypoints.openai.serving_engine.OpenAIServingEngine.shutdown async ¶
Stop accepting requests and release the generator after in-flight work.