stateful_worker
stick_ray.stateful_worker
Module Contents
- exception StatefulSessionNotFound[source]
Bases:
ExceptionException raised when a session id is not found.
Initialize self. See help(type(self)) for accurate signature.
- class StatefulWorker(worker_id, **kwargs)[source]
Represents a stateful worker. Handles sessions for sticky connections, and sends heart beats to router.
- Parameters:
worker_id (str) –
- async ferry(method, data_ref_tuple, session_id)[source]
Ferries a method to this worker, and returns as a task, i.e. an awaitable result.
- Parameters:
- Returns:
the result of the operation, i.e. the task is awaited.
- Raises:
StatefulSessionNotFound if session_id not currently managed, i.e. expired session or it never existed. –
ValueError if session_id is found in the kwargs, as this results in an overwrite. –
- Return type:
Any
- async get_session_state(session_id)[source]
Get the session state for a session id.
- Parameters:
session_id (str) – session id to get state for
- Returns:
the session state
- Raises:
AttributeError if it's not found. –
- Return type:
Any
- async set_session_state(session_id, session_state)[source]
Set the session state for the session id.
- Parameters:
session_id (str) – session id
session_state (Any) – a state object.
- async close_session(*, session_id)[source]
Closes the session for a given session id.
- Parameters:
session_id (str) – sessoin id to close down.