Skip to content

Commit

Permalink
release lock immediately upon shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcountryman committed Nov 20, 2024
1 parent 6c05df1 commit 66991ab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl<T: Task> Scheduler<T> {
#[instrument(skip(self), fields(queue.name = self.queue.name), err)]
pub async fn run(&self) -> Result {
let conn = self.queue.pool.acquire().await?;
let Some(_guard) = try_acquire_advisory_lock(conn, &self.queue_lock).await? else {
let Some(guard) = try_acquire_advisory_lock(conn, &self.queue_lock).await? else {
tracing::debug!("Scheduler could not acquire lock, exiting");
return Ok(());
};
Expand Down Expand Up @@ -290,6 +290,7 @@ impl<T: Task> Scheduler<T> {
}

_ = self.shutdown_token.cancelled() => {
guard.release_now().await?;
break
}

Expand Down

0 comments on commit 66991ab

Please sign in to comment.