diff --git a/src/workers.rs b/src/workers.rs index 781b1ec..e34916a 100644 --- a/src/workers.rs +++ b/src/workers.rs @@ -99,12 +99,6 @@ fn spawn_worker(state: web::Data, task_type: WorkTaskType, concurrency tokio::spawn(async move { loop { - // Wait for notification or poll timeout - tokio::select! { - _ = notify.notified() => {} - _ = tokio::time::sleep(std::time::Duration::from_secs(5)) => {} - } - // Claim pending items let items = match queries::work_queue::claim_next( state.db.conn(), @@ -122,6 +116,11 @@ fn spawn_worker(state: web::Data, task_type: WorkTaskType, concurrency }; if items.is_empty() { + // Nothing to do — wait for notification or poll timeout + tokio::select! { + _ = notify.notified() => {} + _ = tokio::time::sleep(std::time::Duration::from_secs(5)) => {} + } continue; }