Skip to content

Commit

Permalink
Increase job rescheduling timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Luetke (home) committed Feb 18, 2008
1 parent 75b49dc commit 2309a94
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/delayed/job.rb
Expand Up @@ -67,7 +67,7 @@ def perform


def reshedule(message) def reshedule(message)
self.attempts += 1 self.attempts += 1
self.run_at = self.class.time_now + 5.minutes self.run_at = self.class.time_now + (attempts ** 4).seconds
self.last_error = message self.last_error = message
save! save!
end end
Expand Down
4 changes: 2 additions & 2 deletions spec/job_spec.rb
Expand Up @@ -53,7 +53,7 @@ def perform; raise 'did not work'; end
SimpleJob.runs.should == 1 SimpleJob.runs.should == 1
end end


it "should re-schedule by about 5 minutes when it fails to execute properly" do it "should re-schedule by about 1 second at first and increment this more and more minutes when it fails to execute properly" do
Delayed::Job.enqueue ErrorJob.new Delayed::Job.enqueue ErrorJob.new
runner = Delayed::Job.work_off(1) runner = Delayed::Job.work_off(1)
runner.success.should == 0 runner.success.should == 0
Expand All @@ -62,7 +62,7 @@ def perform; raise 'did not work'; end
job = Delayed::Job.find(:first) job = Delayed::Job.find(:first)
job.last_error.should == 'did not work' job.last_error.should == 'did not work'
job.attempts.should == 1 job.attempts.should == 1
job.run_at.should > Time.now + 4.minutes job.run_at.should > Time.now
job.run_at.should < Time.now + 6.minutes job.run_at.should < Time.now + 6.minutes
end end


Expand Down

0 comments on commit 2309a94

Please sign in to comment.