yera.dev.services.session_service
Session service for managing app sessions.
Symbols
SessionService
Service for managing app sessions and generating SSE events.
Methods
SessionService.generate_session_id
generate_session_id() → strGenerate a unique session ID.
Returns
UUID string for the session
SessionService.create_session
create_session(
app: AppFunctionWrapper,
args: tuple = (),
kwargs: dict | None = None,
) → strCreate a new session for the app.
Parameters
The app wrapper to execute.
Positional arguments to pass to the app's invoke method.
Keyword arguments to pass to the app's invoke method.
Returns
Generated session_id
SessionService.get_session
get_session(
session_id: str,
) → SessionStateRetrieve an existing session.
Parameters
Session identifier
Returns
Python app session state
Raises
If session not found
SessionService.add_interaction
add_interaction(
session_id: str,
interaction: dict,
) → NoneAdd an interaction to a session.
Converts the UserInteraction to an InputEvent and pushes it to the executor's EventStream input queue. Also stores the interaction in session state for debugging.
Parameters
Session identifier
Interaction dictionary (UserInteraction format)
Raises
If session not found
If executor not started
SessionService.generate_events
generate_events(
session_id: str,
) → AsyncIterator[str]Generate SSE events from Python app execution.
SessionService.cleanup_session
cleanup_session(
session_id: str,
) → NoneClean up session-specific resources.
Stops the executor process if running and removes the session from internal storage.
Parameters
Session identifier to clean up
Raises
If session not found
SessionService.cleanup_all
cleanup_all() → NoneClean up all sessions.
Iterates through all sessions and calls cleanup_session() for each. Called on server shutdown to ensure no orphaned processes remain.