pub struct ActorProcLauncher { /* private fields */ }Expand description
A ProcLauncher implemented by delegating proc lifecycle
operations to a Python actor.
The spawner actor must implement the ProcLauncher ABC from
monarch._src.actor.proc_launcher, and is responsible for
actually spawning and controlling OS processes (Docker, VMs,
etc.). Rust retains the lifecycle wiring expected by
[BootstrapProcManager]: it initiates launch/terminate/kill
requests and exposes an [oneshot::Receiver] (exit_rx) that
resolves when the spawner reports exit.
§Semantics
- PID is optional: the Python spawner may not expose a real
PID, so
LaunchResult::pidisNone. - Exit reporting is required: the spawner must send exactly
one exit result on the provided exit port. If the port is closed
or the payload cannot be decoded, the receiver resolves to a
ProcExitKind::Failedresult. - Termination is best-effort:
terminateandkillare forwarded to the spawner; success only means the request was delivered.
§Context requirement
ProcLauncher methods don’t take a context parameter, but
sending actor messages does. This launcher stores an
Instance<()> (“client-only” actor) to use as the send context.
The instance is created via [Proc::instance()] and must remain
valid for the lifetime of the launcher.
Implementations§
Source§impl ActorProcLauncher
impl ActorProcLauncher
Sourcepub fn new(
spawner: ActorHandle<PythonActor>,
mailbox: Mailbox,
instance: Instance<()>,
) -> Self
pub fn new( spawner: ActorHandle<PythonActor>, mailbox: Mailbox, instance: Instance<()>, ) -> Self
Create a new actor-based proc launcher.
§Arguments
spawner- Handle to the Python actor implementing theProcLauncherABC.mailbox- Mailbox used to create one-shot exit ports.instance- Send context forActorHandle::send(typically fromProc::instance()). Any valid instance granting send capability is sufficient; it need not beInstance<PythonActor>. Must remain valid for the launcher’s lifetime.
Trait Implementations§
Source§impl Debug for ActorProcLauncher
impl Debug for ActorProcLauncher
Source§impl ProcLauncher for ActorProcLauncher
impl ProcLauncher for ActorProcLauncher
Source§fn launch<'life0, 'life1, 'async_trait>(
&'life0 self,
proc_id: &'life1 ProcId,
opts: LaunchOptions,
) -> Pin<Box<dyn Future<Output = Result<LaunchResult, ProcLauncherError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn launch<'life0, 'life1, 'async_trait>(
&'life0 self,
proc_id: &'life1 ProcId,
opts: LaunchOptions,
) -> Pin<Box<dyn Future<Output = Result<LaunchResult, ProcLauncherError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Spawn a proc by delegating to the Python spawner actor.
This method:
- opens a one-shot mailbox port used for the spawner’s exit notification,
- serializes
(proc_id, LaunchOptions)withcloudpickle, - sends a
CallMethod { launch, ExplicitPort(..) }message to the spawner, - returns immediately with a
LaunchResultwhoseexit_rxcompletes once the spawner reports process termination (or the port closes).
§Notes
pidis alwaysNone: the Rust side does not assume an OS PID exists.- Exit is observed asynchronously via
exit_rx; termination/kill are best-effort requests to the spawner actor rather than direct OS signals. - If decoding the exit payload fails, the returned
exit_rxresolves toProcExitKind::Failedwith a decode error reason.
Source§fn terminate<'life0, 'life1, 'async_trait>(
&'life0 self,
proc_id: &'life1 ProcId,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), ProcLauncherError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn terminate<'life0, 'life1, 'async_trait>(
&'life0 self,
proc_id: &'life1 ProcId,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), ProcLauncherError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Request graceful termination of a proc, with a best-effort timeout.
This delegates to the Python spawner actor’s
terminate(proc_id, timeout_secs) method. The request is sent
fire-and-forget: we do not wait for an acknowledgment, and
there is no guarantee the proc will actually exit within
timeout.
§Errors
Returns ProcLauncherError::Terminate if we fail to:
- import/serialize the request via
cloudpickle, or - send the message to the spawner actor.
Source§fn kill<'life0, 'life1, 'async_trait>(
&'life0 self,
proc_id: &'life1 ProcId,
) -> Pin<Box<dyn Future<Output = Result<(), ProcLauncherError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn kill<'life0, 'life1, 'async_trait>(
&'life0 self,
proc_id: &'life1 ProcId,
) -> Pin<Box<dyn Future<Output = Result<(), ProcLauncherError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Forcefully kill a proc.
This delegates to the Python spawner actor’s kill(proc_id)
method. Like terminate, this is best-effort and
fire-and-forget: success here means the request was serialized
and delivered to the spawner actor, not that the process is
already dead.
§Errors
Returns ProcLauncherError::Kill if we fail to:
- import/serialize the request via
cloudpickle, or - send the message to the spawner actor.
Auto Trait Implementations§
impl Freeze for ActorProcLauncher
impl !RefUnwindSafe for ActorProcLauncher
impl Send for ActorProcLauncher
impl Sync for ActorProcLauncher
impl Unpin for ActorProcLauncher
impl !UnwindSafe for ActorProcLauncher
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].