Skip to content

Commit

Permalink
Explicitly convert FixNums to Integers in time comparison.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgb committed Jan 13, 2012
1 parent ffe7c20 commit cd0e15e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/delayed/backend/data_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def self.find_available(worker_name, limit = 5, max_run_time = Worker.max_run_ti
simple_conditions[:priority.gte] = Worker.min_priority if Worker.min_priority
simple_conditions[:priority.lte] = Worker.max_priority if Worker.max_priority
simple_conditions[:queue] = Worker.queues if Worker.queues.any?
lockable = (all(:run_at.lte => db_time_now) & (all(:locked_at => nil) | all(:locked_at.lt => db_time_now - max_run_time)) | all(:locked_by => worker_name)) & all(:failed_at => nil)
lockable = (all(:run_at.lte => db_time_now) & (all(:locked_at => nil) | all(:locked_at.lt => db_time_now - max_run_time.to_i)) | all(:locked_by => worker_name)) & all(:failed_at => nil)
lockable.all(simple_conditions)
end

Expand All @@ -48,7 +48,7 @@ def lock_exclusively!(max_run_time, worker = worker_name)
# DM doesn't give us the number of rows affected by a collection update
# so we have to circumvent some niceness in DM::Collection here
collection = if locked_by != worker
(self.class.all(:id => id) & (self.class.all(:locked_at => nil) | self.class.all(:locked_at.lt => now - max_run_time)) & self.class.all(:run_at.lte => now))
(self.class.all(:id => id) & (self.class.all(:locked_at => nil) | self.class.all(:locked_at.lt => now - max_run_time.to_i)) & self.class.all(:run_at.lte => now))
else
self.class.all(:id => id, :locked_by => worker)
end
Expand Down

0 comments on commit cd0e15e

Please sign in to comment.