From ba4eb9cf371392acb706ee0cc3306fb614d88454 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 3 Nov 2022 00:27:16 +0100 Subject: [PATCH] worker: remove some unwraps --- src/main.rs | 2 +- src/worker.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 74c2d88..9eb844f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,7 @@ async fn main() { let next_task = if workers_active < config.max_workers { world.dequeue() } else { - Err(Duration::from_secs(3600)) + Err(Duration::from_secs(5)) }; match next_task { Err(duration) => { diff --git a/src/worker.rs b/src/worker.rs index bf75f44..6358ec2 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -34,7 +34,7 @@ pub fn fetch_and_process( timestamps.sort(); let next_interval = if timestamps.len() > 1 { ((*timestamps.last().unwrap() - timestamps[0]) / (timestamps.len() as i32) - ).to_std().unwrap() + ).to_std().unwrap_or(DEFAULT_INTERVAL) .min(DEFAULT_INTERVAL) .max(MIN_INTERVAL) } else { @@ -54,8 +54,8 @@ pub fn fetch_and_process( } } let hosts = hosts.into_iter().collect(); - tx.send(Message::IntroduceHosts { hosts }).unwrap(); - tx.send(Message::Posts { posts }).unwrap(); + let _ = tx.send(Message::IntroduceHosts { hosts }); + let _ = tx.send(Message::Posts { posts }); tx.send(Message::Fetched { host: host.clone(),