Session
app.application.managers.sessionModule for session; coordinates session and worker lifecycles.
See Also
SessionInitializer— attaches runtime collaborators to new sessionsSession— infrastructure runtime object managed here
Layer: Application. Context: Coordinates session and worker lifecycles at this architectural boundary.
SessionManager
Owns the dict of open Session objects and coordinates their
application-layer lifecycle.
The manager keeps session creation and initialization in one place, while
the expensive runtime bootstrap (video reader, runtime view_state, decode
worker) is delegated to SessionInitializer.
| PARAMETER | DESCRIPTION |
|---|---|
app
|
Application that owns the manager and is notified when the active session changes.
TYPE:
|
session_initializer
|
Initializer that constructs and wires new sessions.
TYPE:
|
active_session: Session | None
property
Return the currently active session, if any.
| RETURNS | DESCRIPTION |
|---|---|
Session | None
|
Active session, or |
active_session_id: SessionId | None
property
writable
Return the identifier of the active session, if any.
| RETURNS | DESCRIPTION |
|---|---|
SessionId | None
|
Active session identifier, or |
all_session_ids: Iterable[SessionId]
property
Return identifiers for all managed sessions.
| RETURNS | DESCRIPTION |
|---|---|
Iterable[SessionId]
|
An iterable view of the managed session identifiers. |
all_sessions: Iterable[Session]
property
Return all sessions managed by this manager.
| RETURNS | DESCRIPTION |
|---|---|
Iterable[Session]
|
An iterable view of the managed session objects. |
__init__(app: Application, session_initializer: SessionInitializer | None = None) -> None
bind_session_service(session_service: SessionService)
Bind the session service used for session lifecycle operations.
| PARAMETER | DESCRIPTION |
|---|---|
session_service
|
Service used to coordinate session lifecycle workflows.
TYPE:
|
close_all() -> None
Closes all sessions and clears the session manager.
Flow
- Iterate through all sessions and call their
close()method. - Clear the internal session dictionary.
- Reset the active session ID to an empty view_state using
SessionId("").
create_session_from_video_path(path: str)
Create and register a session for a video file.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Filesystem path of the video to open.
TYPE:
|
Note
Duplicate paths are rejected; video-open and stream errors are logged and skipped without creating a session.
discard_session(s_id: SessionId) -> None
Close and remove the session identified by its session ID.
| PARAMETER | DESCRIPTION |
|---|---|
s_id
|
Identifier of the session to close and remove.
TYPE:
|
get_current_frame_for_session_id(s_id: SessionId) -> RGBFrame | None
get_frame_for_session_id_by_index(frame_index: int, s_id: SessionId) -> RGBFrame | None
Fetches a specific frame directly from the O(1) Ring Buffer, or triggers a seek.
| PARAMETER | DESCRIPTION |
|---|---|
frame_index
|
Zero-based frame index to retrieve.
TYPE:
|
s_id
|
Identifier of the session containing the frame.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RGBFrame | None
|
Decoded RGB frame, or |
get_next_frame_for_session_id(s_id: SessionId) -> RGBFrame | None
get_previous_frame_for_session_id(s_id: SessionId) -> RGBFrame | None
get_session_by_id(s_id: SessionId) -> Session
get_session_state_by_id(s_id: SessionId) -> SessionState
Return the state object belonging to s_id.
| PARAMETER | DESCRIPTION |
|---|---|
s_id
|
Identifier of the session to inspect.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SessionState
|
The |
SessionState
|
annotation state. |
initialize_active_session()
One-time helper to initialize the active session.
stop_all_playback() -> None
Stop all playback.