Closed jupyterkat closed 7 months ago
The unix
module you're using just straight up does not exist on windows compiles. I think you've gotta use a different one for it
I'm afraid the feature doesn't work on linux for me. I enabled the signal
feature, but when I hit C-c nothing happens, and I need to manually kill the process.
let mut sched = JobScheduler::new().await?;
let job = Job::new_async(schedule, move |_, _| {
Box::pin(async move {
// do something
})
})?;
sched.add(job).await?;
sched.shutdown_on_ctrl_c();
sched.set_shutdown_handler(Box::new(|| {
Box::pin(async move {
println!("Shut down done");
})
}));
sched.start().await?;
// run forever
loop {
tokio::time::sleep(Duration::from_millis(500)).await;
}
You can use use tokio::signal::windows::ctrl_c;
in Tokio to implement the functionality of exiting the program with Ctrl-C.
Here's an example:
let mut signal = ctrl_c()?;
// do other things
signal.recv().await;
// stop
sched.shutdown().await?;
Hi @jupyterkat Thanks for the report! I unfortunately don't have access to a Windows machine (Linux/Mac only). I'm leveraging off Tokio's signal feature. Can you perhaps check with upstream Tokio if the signal works on your platform?