pub struct Kernel { /* private fields */ }Expand description
One kernel: a sequence of Python processes (generations), each replaced after a failure.
Implementations§
Source§impl Kernel
impl Kernel
pub fn new( options: KernelOptions, handler: Arc<dyn HostHandler>, ) -> Result<Self, KernelError>
pub fn limits(&self) -> KernelResourceLimits
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Whether a kernel process is up and initialized.
Sourcepub fn stderr_tail(&self) -> String
pub fn stderr_tail(&self) -> String
The bounded tail of the kernel’s raw stderr, for diagnostics.
Sourcepub fn pending_calls(&self) -> usize
pub fn pending_calls(&self) -> usize
How many calls (cells, snapshots, checkpoints) are running or queued, in call order.
pub fn pid(&self) -> Option<u32>
Sourcepub fn memory_usage(&self) -> Option<(u64, Option<u64>)>
pub fn memory_usage(&self) -> Option<(u64, Option<u64>)>
Proportional memory of the kernel’s process tree (Linux, read from /proc) and the tree cap in bytes; None while
no kernel process runs (kernel.ts memoryUsage, for rlm.pool).
Sourcepub fn tree_memory_backend(&self) -> Option<TreeMemoryBackend>
pub fn tree_memory_backend(&self) -> Option<TreeMemoryBackend>
How the running kernel’s tree cap is enforced; None while no kernel process runs.
Sourcepub fn sandbox(&self) -> Option<Mechanism>
pub fn sandbox(&self) -> Option<Mechanism>
The sandbox the running kernel is in; None when unsandboxed or not running.
Sourcepub fn start(&self) -> Result<(), KernelError>
pub fn start(&self) -> Result<(), KernelError>
Starts the kernel process if none runs and waits until it is ready.
Sourcepub fn execute(
&self,
code: &str,
signal: Option<&Signal>,
handler: Option<Arc<dyn HostHandler>>,
) -> Result<ExecutionResult, KernelError>
pub fn execute( &self, code: &str, signal: Option<&Signal>, handler: Option<Arc<dyn HostHandler>>, ) -> Result<ExecutionResult, KernelError>
Runs a cell. handler, when given, serves this cell’s host requests instead of the kernel’s handler. The first
cell after a recovery starts its stderr with the recovery notice (ContinuityReport::render).
Sourcepub fn execute_cell(
&self,
code: &str,
signal: Option<&Signal>,
handler: Option<Arc<dyn HostHandler>>,
) -> Result<KernelReply, KernelError>
pub fn execute_cell( &self, code: &str, signal: Option<&Signal>, handler: Option<Arc<dyn HostHandler>>, ) -> Result<KernelReply, KernelError>
Kernel::execute with the structured recovery report of the first cell after a recovery.
Sourcepub fn reset_scratch(&self) -> Result<ExecutionResult, KernelError>
pub fn reset_scratch(&self) -> Result<ExecutionResult, KernelError>
Clears invocation scratch while keeping the API bindings and the declared state dict.
Sourcepub fn snapshot(&self, path: Option<&Path>) -> Result<KernelReply, KernelError>
pub fn snapshot(&self, path: Option<&Path>) -> Result<KernelReply, KernelError>
Saves the namespace’s restorable names to path (default: the configured snapshot path), signed by the host.
The reply’s snapshot lists saved names and every skipped name with a reason; a failure leaves the previous
file intact.
Sourcepub fn restore(&self, path: Option<&Path>) -> Result<KernelReply, KernelError>
pub fn restore(&self, path: Option<&Path>) -> Result<KernelReply, KernelError>
Restores a host-verified snapshot from path (default: the configured snapshot path). Unsigned, tampered or
foreign-key snapshots are refused before the kernel reads them, and the namespace stays untouched.
Sourcepub fn last_recovery(&self) -> Option<ContinuityReport>
pub fn last_recovery(&self) -> Option<ContinuityReport>
The latest recovery’s report, also after it was delivered with a cell.
Sourcepub fn checkpoint(&self) -> Option<SnapshotReport>
pub fn checkpoint(&self) -> Option<SnapshotReport>
The latest checkpoint written to the configured snapshot path.