mirror of
https://github.com/zaphar/runwhen.git
synced 2025-07-25 21:09:51 -04:00
Handle the PoisonError case somewhat gracefully.
This commit is contained in:
parent
3641b1b238
commit
805d547f2d
29
src/file.rs
29
src/file.rs
@ -52,14 +52,19 @@ fn spawn_runner_thread(lock: Arc<Mutex<bool>>, cmd: String, poll: Duration) {
|
|||||||
// Wait our requisit number of seconds
|
// Wait our requisit number of seconds
|
||||||
thread::sleep(poll);
|
thread::sleep(poll);
|
||||||
// Default to not running the command.
|
// Default to not running the command.
|
||||||
let mut signal = lock.lock().unwrap();
|
match lock.lock() {
|
||||||
if *signal {
|
Ok(mut signal) => if *signal {
|
||||||
// set signal to false so we won't trigger on the
|
// set signal to false so we won't trigger on the
|
||||||
// next loop iteration unless we recieved more events.
|
// next loop iteration unless we recieved more events.
|
||||||
*signal = false;
|
*signal = false;
|
||||||
// Run our command!
|
// Run our command!
|
||||||
if let Err(err) = run_cmd(&cmd) {
|
if let Err(err) = run_cmd(&cmd) {
|
||||||
println!("{:?}", err)
|
println!("{:?}", err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
println!("Unexpected error; {}", err);
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,7 +101,13 @@ fn wait_for_fs_events(lock: Arc<Mutex<bool>>,
|
|||||||
}
|
}
|
||||||
WatchEventType::Changed => {
|
WatchEventType::Changed => {
|
||||||
let mut signal = lock.lock().unwrap();
|
let mut signal = lock.lock().unwrap();
|
||||||
*signal = true;
|
match lock.lock() {
|
||||||
|
Ok(mut signal) => *signal = true,
|
||||||
|
Err(err) => {
|
||||||
|
println!("Unexpected error; {}", err);
|
||||||
|
return Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user