rfdonnelly / jobrnr

Jobrnr runs jobs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Repeat jobs hold up other jobs

rfdonnelly opened this issue · comments

Repeat jobs head of line block the job queue until all iterations have been scheduled. See

job_queue.shift if job_instance.job.state.scheduled?

Instead, repeat jobs should be sent to the back of the queue after scheduling repeat job iteration. This will give other jobs a change to schedule.

diff --git a/lib/jobrnr/job/dispatch.rb b/lib/jobrnr/job/dispatch.rb
index 4042513..8e1bab7 100644
--- a/lib/jobrnr/job/dispatch.rb
+++ b/lib/jobrnr/job/dispatch.rb
@@ -110,7 +110,12 @@ module Jobrnr
             slot: slot,
             log: log_filename(slot)
           )
-          job_queue.shift if job_instance.job.state.scheduled?
+
+          if job_instance.job.state.scheduled?
+            job_queue.shift
+          else
+            job_queue.rotate!
+          end

           plugins.pre_instance(Jobrnr::PreInstanceMessage.new(job_instance, options))
           message(job_instance)