fix not responding to interrupt

This commit is contained in:
Robin Appelman 2026-10-14 00:23:21 +02:00
commit 82aaf985ef

View file

@ -13,8 +13,8 @@ use std::hash::{Hash, Hasher};
use std::str::FromStr; use std::str::FromStr;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::thread::sleep; use std::thread::sleep;
use std::time::Duration;
use syndication::Feed; use syndication::Feed;
use std::time::{Duration, Instant};
use tracing::{debug, error, info, instrument, warn}; use tracing::{debug, error, info, instrument, warn};
use ureq::http::header::{HeaderValue, USER_AGENT}; use ureq::http::header::{HeaderValue, USER_AGENT};
use ureq::http::Response; use ureq::http::Response;
@ -69,7 +69,14 @@ fn main_loop(config: Config) {
} }
} }
sleep(config.interval()); interruptable_sleep(config.interval());
}
}
fn interruptable_sleep(duration: Duration) {
let target = Instant::now() + duration;
while Instant::now() < target && RUNNING.load(Ordering::SeqCst) {
sleep(Duration::from_millis(100));
} }
} }