From d6f18c8f8219cce355993ecd5a375c8f1603f923 Mon Sep 17 00:00:00 2001 From: Flix Date: Thu, 28 Dec 2023 20:11:19 +0100 Subject: [PATCH] fix: Decrease currently running jobs on panics too --- src/job.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/job.rs b/src/job.rs index 69ff30e..e5b2319 100644 --- a/src/job.rs +++ b/src/job.rs @@ -131,12 +131,14 @@ impl CurrentJob { let db = self.db.clone(); tracing::trace!("Starting job with ID {id}."); - let res = function(self).await; + let res = tokio::spawn(function(self)).await; currently_running.fetch_sub(1, Ordering::Relaxed); - // Handle the job's error - if let Err(err) = res { - db.handle_job_error(err); + // Handle the job's error. + match res { + Err(_) => tracing::warn!("Job with ID {id} panicked!"), + Ok(Err(err)) => db.handle_job_error(err), + Ok(_) => {} } db.notify().await?;