class Resque::Job
Public Class Methods
job_from_same_queue_is_currently_being_run?(queue)
click to toggle source
Given a queue name determine whether there is a worker currently working on a job from the same queue return true
# File lib/resque/plugins/real_serial_queues.rb, line 13 def self.job_from_same_queue_is_currently_being_run?(queue) Worker.working.each do |worker| processing_job = worker.job next unless processing_job processing_queue = processing_job['queue'] next unless processing_queue return true if processing_queue == queue end false end
reserve(queue)
click to toggle source
Given a string queue name, returns an instance of Resque::Job
if any jobs are available. If not, returns nil. This is a resque method overridden to first check if there is another job from the queue being checked currently being worked on. This check can be bypassed by setting non_serial_queues via Resque::Plugins::RealSerialQueues.config=
in your Resque
config
# File lib/resque/plugins/real_serial_queues.rb, line 34 def self.reserve(queue) non_serial_queues = Resque::Plugins::RealSerialQueues.non_serial_queues unless non_serial_queues && non_serial_queues.include?(queue) return if job_from_same_queue_is_currently_being_run?(queue) end return unless payload = Resque.pop(queue) new(queue, payload) end