pub struct ProcessExecutor { /* private fields */ }Expand description
Process-based executor that runs cells in isolated worker processes.
Unlike LinearExecutor, this executor can truly interrupt cell execution
by killing the worker process. This provides:
- Immediate interruption (no need for cooperative checks)
- Crash isolation (panics don’t affect the server)
- Memory isolation (runaway cells can’t OOM the server)
Implementations§
Source§impl ProcessExecutor
impl ProcessExecutor
Sourcepub fn with_state(state: StateManager) -> Self
pub fn with_state(state: StateManager) -> Self
Create with an existing state manager.
Sourcepub fn with_warm_pool(
state_dir: impl AsRef<Path>,
pool_size: usize,
) -> Result<Self>
pub fn with_warm_pool( state_dir: impl AsRef<Path>, pool_size: usize, ) -> Result<Self>
Create with a pre-warmed worker pool.
Sourcepub fn set_callback(&mut self, callback: impl ExecutionCallback + 'static)
pub fn set_callback(&mut self, callback: impl ExecutionCallback + 'static)
Set the execution callback for progress reporting.
Sourcepub fn set_abort_handle(&mut self, handle: AbortHandle)
pub fn set_abort_handle(&mut self, handle: AbortHandle)
Set the abort handle for interruption.
Sourcepub fn abort_handle(&self) -> Option<&AbortHandle>
pub fn abort_handle(&self) -> Option<&AbortHandle>
Get the current abort handle.
Sourcepub fn register_cell(&mut self, compiled: CompiledCell, dep_count: usize)
pub fn register_cell(&mut self, compiled: CompiledCell, dep_count: usize)
Register a compiled cell for execution.
Unlike LinearExecutor::load_cell, this doesn’t actually load the dylib.
The worker process will load it when executing.
Sourcepub fn unregister_cell(&mut self, cell_id: CellId) -> Option<CompiledCell>
pub fn unregister_cell(&mut self, cell_id: CellId) -> Option<CompiledCell>
Unregister a cell.
Sourcepub fn is_registered(&self, cell_id: CellId) -> bool
pub fn is_registered(&self, cell_id: CellId) -> bool
Check if a cell is registered.
Sourcepub fn execute_cell(
&mut self,
cell_id: CellId,
inputs: &[Arc<BoxedOutput>],
) -> Result<BoxedOutput>
pub fn execute_cell( &mut self, cell_id: CellId, inputs: &[Arc<BoxedOutput>], ) -> Result<BoxedOutput>
Execute a single cell with the given inputs.
This runs the cell in a worker process that can be killed for interruption.
Sourcepub fn execute_cell_with_widgets(
&mut self,
cell_id: CellId,
inputs: &[Arc<BoxedOutput>],
widget_values_json: Vec<u8>,
) -> Result<(BoxedOutput, Vec<u8>)>
pub fn execute_cell_with_widgets( &mut self, cell_id: CellId, inputs: &[Arc<BoxedOutput>], widget_values_json: Vec<u8>, ) -> Result<(BoxedOutput, Vec<u8>)>
Execute a single cell with the given inputs and widget values.
This runs the cell in a worker process that can be killed for interruption. Returns the cell output and any registered widget definitions as JSON.
Sourcepub fn execute_and_store(
&mut self,
cell_id: CellId,
inputs: &[Arc<BoxedOutput>],
) -> Result<()>
pub fn execute_and_store( &mut self, cell_id: CellId, inputs: &[Arc<BoxedOutput>], ) -> Result<()>
Execute a cell and store the output in the state manager.
Sourcepub fn execute_in_order(
&mut self,
order: &[CellId],
deps: &HashMap<CellId, Vec<CellId>>,
) -> Result<()>
pub fn execute_in_order( &mut self, order: &[CellId], deps: &HashMap<CellId, Vec<CellId>>, ) -> Result<()>
Execute cells in the given order, resolving dependencies from state.
Sourcepub fn kill_current(&self)
pub fn kill_current(&self)
Kill the currently executing cell immediately.
This is the key feature - we can terminate the worker process mid-computation without any cooperation from the cell. This method is thread-safe and can be called from any thread.
Sourcepub fn get_kill_handle(&self) -> Option<ExecutorKillHandle>
pub fn get_kill_handle(&self) -> Option<ExecutorKillHandle>
Get a handle that can be used to kill the current execution from another thread.
Returns None if no execution is in progress.
The returned handle is safe to clone and use from any thread.
Sourcepub fn abort(&mut self)
pub fn abort(&mut self)
Abort execution and kill any running cell.
Sets the abort flag and kills the current worker.
Sourcepub fn state(&self) -> &StateManager
pub fn state(&self) -> &StateManager
Get a reference to the state manager.
Sourcepub fn state_mut(&mut self) -> &mut StateManager
pub fn state_mut(&mut self) -> &mut StateManager
Get a mutable reference to the state manager.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ProcessExecutor
impl !RefUnwindSafe for ProcessExecutor
impl Send for ProcessExecutor
impl Sync for ProcessExecutor
impl Unpin for ProcessExecutor
impl !UnwindSafe for ProcessExecutor
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.