pub struct Worker {
pub(crate) child: Child,
pub(crate) stdin: Option<ChildStdin>,
pub(crate) stdout: BufReader<ChildStdout>,
}Expand description
A running worker process.
Fields§
§child: Child§stdin: Option<ChildStdin>§stdout: BufReader<ChildStdout>Implementations§
Source§impl Worker
impl Worker
Sourcepub fn spawn(python: &Path, script: &Path, args: &[String]) -> Result<Worker>
pub fn spawn(python: &Path, script: &Path, args: &[String]) -> Result<Worker>
subprocess.Popen([python, script, *args], stdin=PIPE, stdout=PIPE)
with stderr inherited, as every Python caller leaves it.
Sourcepub fn read_line(&mut self) -> Result<String>
pub fn read_line(&mut self) -> Result<String>
proc.stdout.readline(): the next line including its newline, or
an empty string at end of stream.
Sourcepub fn wait_ready(
&mut self,
on_noise: impl FnMut(&str),
) -> Result<Option<Value>>
pub fn wait_ready( &mut self, on_noise: impl FnMut(&str), ) -> Result<Option<Value>>
Read lines until one parses as JSON with a truthy ready, returning
it. Non-JSON lines and other messages go to on_noise. None means
the worker exited first.
Auto Trait Implementations§
impl Freeze for Worker
impl RefUnwindSafe for Worker
impl Send for Worker
impl Sync for Worker
impl Unpin for Worker
impl UnsafeUnpin for Worker
impl UnwindSafe for Worker
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