lib/resque/worker.rb
def reserve(timeout=5)
      available_queues = Job.reservable_queues(queues)
      if available_queues.empty?
        sleep timeout # prevent busy-wait.
      elsif job = Job.reserve(available_queues, timeout)
        log! "Found job on #{job.queue}"
        return job
      end
      nil
    rescue Exception => e
      log "Error reserving job: #{e.inspect}"
      log e.backtrace.join("\n")
      raise e
    end
# Attempts to grab a job off one of the provided queues. Returns
# nil if no job can be found.
#
# The timeout defines how long to wait for a blocking pop, if any queues are
# available to check for jobs, or how long to sleep if no queues are
# available. Queues may not be available because resque hasn't created or
# tracked any queues yet, or because no queues are passing their
# before_reserve hooks.
#
# timeout - an Integer timeout in seconds. Defaults to 5.
#
# Returns a Job or nil.
Attempts to grab a job off one of the provided queues. Returns
nil if no job can be found.

The timeout defines how long to wait for a blocking pop, if any queues are
available to check for jobs, or how long to sleep if no queues are
available. Queues may not be available because resque hasn't created or
tracked any queues yet, or because no queues are passing their
before_reserve hooks.

an Integer timeout in seconds. Defaults to 5.

Returns a Job or nil.
Attempts to grab a job off one of the provided queues . Returns nil if no job can be found . The timeout defines how long to wait for a blocking pop if any queues are available to check for jobs or how long to sleep if no queues are available . Queues may not be available because resque hasn ' t created or tracked any queues yet or because no queues are passing their before_reserve hooks . an Integer timeout in seconds . Defaults to 5 . Returns a Job or nil .
def reserve(timeout=5)
      available_queues = Job.reservable_queues(queues)
      if available_queues.empty?
        sleep timeout 
      elsif job = Job.reserve(available_queues, timeout)
        log! "Found job on #{job.queue}"
        return job
      end
      nil
    rescue Exception => e
      log "Error reserving job: #{e.inspect}"
      log e.backtrace.join("\n")
      raise e
    end
def reserve ( timeout = 5 ) available_queues = Job . reservable_queues ( queues ) if available_queues . empty? sleep timeout elsif job = Job . reserve ( available_queues , timeout ) log! "Found job on #{job.queue}" return job end nil rescue Exception => e log "Error reserving job: #{e.inspect}" log e . backtrace . join ( "\n" ) raise e end
Attempts to grab a job off one of the provided queues.
Attempts to grab a job off one of the provided queues .
# prevent busy-wait.
timeout