Skip to content

Commit

Permalink
fix: Decrease currently running jobs on panics too
Browse files Browse the repository at this point in the history
  • Loading branch information
FlixCoder committed Dec 28, 2023
1 parent f5d2bde commit d6f18c8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;

Expand Down

0 comments on commit d6f18c8

Please sign in to comment.