cadrumo.adapters.persistence.storage.master_key.live_sessions module¶
Process-wide registry of key-holding bucket sessions.
The active-session binding is a ContextVar, which is the
right shape for ordinary work: each thread and each asyncio.Task gets its
own active session, and an encrypt path can never see a sibling context’s key.
An embedding host’s lifetime watchdog also needs one public shutdown operation
that can zeroise sessions held by other contexts before an abrupt exit. This
module owns that process-wide emergency boundary.
Registration is a weakref.WeakSet, so a session that is dropped
without an explicit close is garbage collected normally and the registry never
extends the lifetime of key material it is meant to destroy.
See also
close_active_bucket_session()The ordinary, context-scoped close every normal caller wants.
- register_live_session(session)[source]¶
Record
sessionas a live key holder for emergency zeroisation.- Return type:
- Parameters:
session (BucketSession)
- close_all_live_bucket_sessions()[source]¶
Close every registered session, zeroising its keys.
The cross-context counterpart to
close_active_bucket_session(), for the interpreter exit hook and an embedding watchdog’s pre-exit hook before anos._exitthat would otherwise skip both. One session’s failure never prevents the remaining sessions from being zeroised.- Return type:
- Returns:
The number of sessions this call transitioned from unsealed to sealed.