Skip to content

Commit

Permalink
Fix for typo, also return jobs in random order to yield site to furth…
Browse files Browse the repository at this point in the history
…er avoid locking issues
  • Loading branch information
Tobias Lütke committed Nov 26, 2008
1 parent 916e9f2 commit d0a9c2d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/delayed/job.rb
Expand Up @@ -104,9 +104,11 @@ def self.find_available(limit = 5, max_run_time = MAX_RUN_TIME)


conditions.unshift(sql) conditions.unshift(sql)


ActiveRecord::Base.silence do records = ActiveRecord::Base.silence do
find(:all, :conditions => conditions, :order => NextTaskOrder, :limit => limit) find(:all, :conditions => conditions, :order => NextTaskOrder, :limit => limit)
end end

records.sort { rand() }
end end


# Get the payload of the next job we can get an exclusive lock on. # Get the payload of the next job we can get an exclusive lock on.
Expand Down
2 changes: 1 addition & 1 deletion lib/delayed/worker.rb
Expand Up @@ -36,7 +36,7 @@ def start
end end


ensure ensure
Delayed::Job..clear_locks! Delayed::Job.clear_locks!
end end


def say(text) def say(text)
Expand Down

0 comments on commit d0a9c2d

Please sign in to comment.