lib/resque/worker.rb
def work(interval = 5.0, &block)
      interval = Float(interval)
      $0 = "resque: Starting"
      startup

      loop do
        break if shutdown?

        pause if should_pause?

        if job = reserve(interval)
          process_job(job, &block)
          @child = nil
        else
          break if interval.zero?
          Resque.logger.debug "Timed out after #{interval} seconds"
          procline paused? ? "Paused" : "Waiting for #{@queues.join(',')}"
        end
      end

      unregister_worker
    rescue Exception => exception
      unregister_worker(exception)
    end
# This is the main workhorse method. Called on a Worker instance,
# it begins the worker life cycle.
#
# The following events occur during a worker's life cycle:
#
# 1. Startup:   Signals are registered, dead workers are pruned,
#               and this worker is registered.
# 2. Work loop: Jobs are pulled from a queue and processed.
# 3. Teardown:  This worker is unregistered.
#
# Can be passed a float representing the polling frequency.
# The default is 5 seconds, but for a semi-active site you may
# want to use a smaller value.
#
# Also accepts a block which will be passed the job as soon as it
# has completed processing. Useful for testing.
This is the main workhorse method. Called on a Worker instance,
it begins the worker life cycle.

The following events occur during a worker's life cycle.

1. Startup:   Signals are registered, dead workers are pruned,
and this worker is registered.
2. Work loop: Jobs are pulled from a queue and processed.
3. Teardown:  This worker is unregistered.

Can be passed a float representing the polling frequency.
The default is 5 seconds, but for a semi-active site you may
want to use a smaller value.

Also accepts a block which will be passed the job as soon as it
has completed processing. Useful for testing.
This is the main workhorse method . Called on a Worker instance it begins the worker life cycle . The following events occur during a worker ' s life cycle . 1 . Startup : Signals are registered dead workers are pruned and this worker is registered . 2 . Work loop : Jobs are pulled from a queue and processed . 3 . Teardown : This worker is unregistered . Can be passed a float representing the polling frequency . The default is 5 seconds but for a semi - active site you may want to use a smaller value . Also accepts a block which will be passed the job as soon as it has completed processing . Useful for testing .
def work(interval = 5.0, &block)
      interval = Float(interval)
      $0 = "resque: Starting"
      startup
      loop do
        break if shutdown?
        pause if should_pause?
        if job = reserve(interval)
          process_job(job, &block)
          @child = nil
        else
          break if interval.zero?
          Resque.logger.debug "Timed out after #{interval} seconds"
          procline paused? ? "Paused" : "Waiting for #{@queues.join(',')}"
        end
      end
      unregister_worker
    rescue Exception => exception
      unregister_worker(exception)
    end
def work ( interval = 5.0 , & block ) interval = Float ( interval ) $0 = "resque: Starting" startup loop do break if shutdown? pause if should_pause? if job = reserve ( interval ) process_job ( job , & block ) @child = nil else break if interval . zero? Resque . logger . debug "Timed out after #{interval} seconds" procline paused? ? "Paused" : "Waiting for #{@queues.join(',')}" end end unregister_worker rescue Exception => exception unregister_worker ( exception ) end
This is the main workhorse method.
This is the main workhorse method .
interval
block