Skip to content

Commit

Permalink
Allowed the poll interval to be specified as a floating point number.
Browse files Browse the repository at this point in the history
This enables using poll intervals shorter than a second; for example, specifying INTERVAL=0.25 is now possible.
  • Loading branch information
artob authored and defunkt committed Mar 17, 2011
1 parent dbd04d6 commit 9377687
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/resque/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ def validate_queues
# 2. Work loop: Jobs are pulled from a queue and processed.
# 3. Teardown: This worker is unregistered.
#
# Can be passed an integer representing the polling frequency.
# 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, &block)
def work(interval = 5.0, &block)
interval = interval.to_f
$0 = "resque: Starting"
startup

Expand All @@ -133,10 +134,10 @@ def work(interval = 5, &block)
done_working
@child = nil
else
break if interval.to_i == 0
log! "Sleeping for #{interval.to_i}"
break if interval.zero?
log! "Sleeping for #{interval} seconds"
procline @paused ? "Paused" : "Waiting for #{@queues.join(',')}"
sleep interval.to_i
sleep interval
end
end

Expand Down

0 comments on commit 9377687

Please sign in to comment.