Skip to main content

Kernel

Struct Kernel 

Source
pub struct Kernel { /* private fields */ }
Expand description

One kernel: a sequence of Python processes (generations), each replaced after a failure.

Implementations§

Source§

impl Kernel

Source

pub fn new( options: KernelOptions, handler: Arc<dyn HostHandler>, ) -> Result<Self, KernelError>

Source

pub fn limits(&self) -> KernelResourceLimits

Source

pub fn is_running(&self) -> bool

Whether a kernel process is up and initialized.

Source

pub fn stderr_tail(&self) -> String

The bounded tail of the kernel’s raw stderr, for diagnostics.

Source

pub fn pending_calls(&self) -> usize

How many calls (cells, snapshots, checkpoints) are running or queued, in call order.

Source

pub fn pid(&self) -> Option<u32>

Source

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).

Source

pub fn tree_memory_backend(&self) -> Option<TreeMemoryBackend>

How the running kernel’s tree cap is enforced; None while no kernel process runs.

Source

pub fn sandbox(&self) -> Option<Mechanism>

The sandbox the running kernel is in; None when unsandboxed or not running.

Source

pub fn start(&self) -> Result<(), KernelError>

Starts the kernel process if none runs and waits until it is ready.

Source

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).

Source

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.

Source

pub fn reset_scratch(&self) -> Result<ExecutionResult, KernelError>

Clears invocation scratch while keeping the API bindings and the declared state dict.

Source

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.

Source

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.

Source

pub fn last_recovery(&self) -> Option<ContinuityReport>

The latest recovery’s report, also after it was delivered with a cell.

Source

pub fn checkpoint(&self) -> Option<SnapshotReport>

The latest checkpoint written to the configured snapshot path.

Source

pub fn shutdown(&self)

Permanently closes this kernel: kills its process tree, rejects every call, and waits (bounded) for the exit.

Trait Implementations§

Source§

impl Drop for Kernel

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Kernel

§

impl !UnwindSafe for Kernel

§

impl Forget for Kernel

§

impl Freeze for Kernel

§

impl Move for Kernel

§

impl Send for Kernel

§

impl Sync for Kernel

§

impl Unpin for Kernel

§

impl UnsafeUnpin for Kernel

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.