Skip to content

Commit

Permalink
Implement Job.clear_locks! for mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Jan 2, 2010
1 parent 81a09e1 commit 7fce10c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/delayed/backend/mongo.rb
Expand Up @@ -41,6 +41,11 @@ def self.find_available(worker_name, limit = 5, max_run_time = Worker.max_run_ti
all(conditions)
end

# When a worker is exiting, make sure we don't have any locked jobs.
def self.clear_locks!(worker_name)
collection.update({:locked_by => worker_name}, {"$set" => {:locked_at => nil, :locked_by => nil}}, :multi => true)
end

# Lock this job for this worker.
# Returns true if we have the lock, false otherwise.
def lock_exclusively!(max_run_time, worker = worker_name)
Expand Down

0 comments on commit 7fce10c

Please sign in to comment.