Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Resque plugin for ensuring only one instance of your job is running at a time.
Ruby
Branch: master
Pull request Compare This branch is 4 commits ahead, 3 commits behind defunkt:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/resque/plugins
test
.gitignore
Gemfile
LICENSE
README.md
Rakefile
resque-fine-grained-locks.gemspec

README.md

Resque Fine-Grained Locks

A [Resque][rq] plugin. Requires Resque 1.7.0.

If you want only one instance of your job queued at a time, extend it with Resque::Plugins::QueueLock. You will be able to enqueue another job if one is currently executing.

For example:

require 'resque/plugins/queue_lock'

class UpdateNetworkGraph
  extend Resque::Plugins::QueueLock

  def self.perform(repo_id)
    heavy_lifting
  end
end

If you want only one instance of your job to execute at a time, extend it with Resque::Plugins::ExecutionLock. You can optionally use resque-retry if you want to retry locked jobs without them failing.

For example:

require 'resque/plugins/execution_lock'

class UpdateNetworkGraph extend Resque::Plugins::Retry extend Resque::Plugins::ExecutionLock

@retry_exceptions = [ Resque::Plugins::ExecutionLock::JobIsLocked ]

def self.perform(repo_id) heavy_lifting end end

And in your resque initializer (config/resque.rb):

require 'resque/failure/multiple'

Resque::Failure::MultipleWithRetrySuppression.classes = [Resque::Plugins::ExecutionLock::JobIsLocked] Resque::Failure.backend = Resque::Failure::MultipleWithRetrySuppression

Something went wrong with that request. Please try again.