session
¶
Per-connection session lifecycle for the streaming server.
Each WebSocket opens exactly one :class:Session. :class:SessionManager
enforces the generation_segment_cap and session_timeout_seconds
budgets from :class:fastvideo.api.StreamingConfig.
Classes¶
fastvideo.entrypoints.streaming.session.InvalidSessionTransition
¶
Bases: RuntimeError
Raised when a session is asked to transition along an illegal edge.
fastvideo.entrypoints.streaming.session.Session
dataclass
¶
Session(id: str = (lambda: hex)(), state: SessionState = INITIALIZING, created_at: float = monotonic(), last_activity: float = monotonic(), client_id: str | None = None, preset: str | None = None, preset_label: str | None = None, curated_prompts: list[str] = list(), segment_idx: int = 0, enhancement_enabled: bool = False, auto_extension_enabled: bool = False, loop_generation_enabled: bool = False, single_clip_mode: bool = False, generation_paused: bool = False, stream_mode: str = 'av_fmp4', gpu_id: int | None = None, continuation_state: ContinuationState | None = None, metadata: dict[str, Any] = dict())
Functions¶
fastvideo.entrypoints.streaming.session.Session.transition
¶
transition(target: SessionState) -> None
Move to target if the edge is allowed.
Raises :class:InvalidSessionTransition on illegal moves. The
self-loop on ACTIVE is legal so the server can re-assert
ACTIVE on segment completion without special casing.
Source code in fastvideo/entrypoints/streaming/session.py
fastvideo.entrypoints.streaming.session.SessionManager
¶
Registers sessions and enforces per-server session limits.
Source code in fastvideo/entrypoints/streaming/session.py
Functions¶
fastvideo.entrypoints.streaming.session.SessionManager.reap_timed_out
¶
Return the ids of sessions that have exceeded the idle timeout.
The caller is responsible for actually closing them — this
method only identifies dead sessions so the server can emit
session_timeout frames before dropping the WebSocket.
TODO: unused until a background driver calls it. Per-connection idle enforcement currently happens via asyncio.wait_for on receive_json; this helper catches sessions stuck before any receive (e.g. future QUEUED state) and is expected to be wired into the GPU-pool reaper.
Source code in fastvideo/entrypoints/streaming/session.py
fastvideo.entrypoints.streaming.session.SessionRejected
¶
Bases: RuntimeError
Raised when session creation fails (queue full, auth, etc.).