SnakeBridge.SessionContext (SnakeBridge v0.7.4)
View SourceProvides scoped session context for Python calls.
Usage
SnakeBridge.SessionContext.with_session(fn ->
# All Python calls here use the same session
Python.some_function()
Python.another_function()
end)
Summary
Functions
Clears the current session context.
Creates a new session context.
Gets the current session context from the process dictionary.
Sets the current session context in the process dictionary.
Executes a function within a session context.
Types
@type t() :: %SnakeBridge.SessionContext{ created_at: integer(), max_refs: pos_integer(), owner_pid: pid(), session_id: String.t(), tags: map(), ttl_seconds: pos_integer() }
Functions
@spec clear_current() :: t() | nil
Clears the current session context.
Creates a new session context.
@spec current() :: t() | nil
Gets the current session context from the process dictionary.
Sets the current session context in the process dictionary.
@spec with_session((-> result)) :: result when result: term()
Executes a function within a session context.
The session is automatically registered and will be released when the owner process dies.