pub struct Supervisor { /* private fields */ }Expand description
Python 进程的监督者,负责其完整生命周期并转发调用、取消与事件。
通过 Supervisor::new 创建(返回 Arc),Supervisor::start 启动,
Supervisor::shutdown 关闭。
Implementations§
Source§impl Supervisor
impl Supervisor
Sourcepub fn new(config: SupervisorConfig, sink: Arc<dyn EventSink>) -> Arc<Self> ⓘ
pub fn new(config: SupervisorConfig, sink: Arc<dyn EventSink>) -> Arc<Self> ⓘ
创建处于 Status::Starting 的监督者,不会启动进程;需随后调用 Supervisor::start。
Sourcepub fn start(self: &Arc<Self>)
pub fn start(self: &Arc<Self>)
在后台启动 Python 进程并开始监督,立即返回。
只应调用一次:每次调用都会启动一个独立的监督循环;Supervisor::shutdown 之后再调用也
无法重新启动。
Sourcepub async fn call(
&self,
cmd: &str,
args: Payload,
channels: Vec<(String, ChannelSink)>,
opts: CallOptions,
) -> Result<Payload>
pub async fn call( &self, cmd: &str, args: Payload, channels: Vec<(String, ChannelSink)>, opts: CallOptions, ) -> Result<Payload>
调用 Python 命令 cmd,必要时先等待运行时就绪。
运行时处于 Starting 时最多等待 handshake_timeout;调用本身的超时规则见 Bridge::call。
§Errors
runtime_unavailable:运行时未就绪、已停止或已崩溃,或等待就绪超时;protocol_mismatch等:运行时处于Status::Failed时返回导致失败的原始错误;runtime_exited:调用进行中 Python 进程退出;- 其余错误(
invalid_args、timeout、cancelled、frame_too_large、Python 返回的错误等) 见Bridge::call。
Sourcepub fn cancel(&self, window: &str, client_id: &str) -> bool
pub fn cancel(&self, window: &str, client_id: &str) -> bool
取消 window 窗口中客户端 id 为 client_id 的调用,返回是否找到该调用。
运行时未运行时仍会让等待者以 cancelled 失败,只是不再通知 Python。详见 Bridge::cancel。
Auto Trait Implementations§
impl !Freeze for Supervisor
impl !RefUnwindSafe for Supervisor
impl !UnwindSafe for Supervisor
impl Forget for Supervisor
impl Move for Supervisor
impl Send for Supervisor
impl Sync for Supervisor
impl Unpin for Supervisor
impl UnsafeUnpin for Supervisor
Blanket Implementations§
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
Mutably borrows from an owned value. Read more