Manages Python session lifecycle with process monitoring.
Sessions are automatically released when all owner processes die, preventing memory leaks in long-running applications.
Cleanup logs are opt-in via config. Use
config :snakebridge, session_cleanup_log_level: :debug to enable.
Summary
Functions
Returns a specification to start this module under a supervisor.
Lists all refs in a session.
Registers a ref with its session for tracking.
Registers a session owner process. The session will be released when the last owner dies.
Explicitly releases a session and all its refs.
Checks if a session exists.
Unregisters a session without releasing refs on the Python side.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec list_refs(session_id()) :: [ref()]
Lists all refs in a session.
@spec register_ref(session_id(), ref()) :: :ok | {:error, :session_not_found}
Registers a ref with its session for tracking.
@spec register_session(session_id(), pid()) :: :ok
Registers a session owner process. The session will be released when the last owner dies.
@spec release_session(session_id()) :: :ok
Explicitly releases a session and all its refs.
@spec session_exists?(session_id()) :: boolean()
Checks if a session exists.
@spec unregister_session(session_id()) :: :ok
Unregisters a session without releasing refs on the Python side.
Typically called when manually cleaning up before process death, or when the caller has already released the session.