echo_stream/
echo_stream.rs1use interactive_process::InteractiveProcess;
2use std::{process::Command, thread::sleep, time::Duration};
3
4fn main() {
5 let mut cmd = Command::new("examples/echo_stream.py");
6 let mut proc = InteractiveProcess::new(&mut cmd, |line| {
7 println!("Got: {}", line.unwrap());
8 })
9 .unwrap();
10
11 proc.send("data1").unwrap();
12 sleep(Duration::from_secs(1));
13 proc.send("data2").unwrap();
14 sleep(Duration::from_secs(1));
15 proc.send("data3").unwrap();
16
17 sleep(Duration::from_millis(1));
20
21 proc.close().kill().unwrap();
22}