Skip to content

Commit

Permalink
Merge remote branch 'Viximo/ci-sleep-patch'
Browse files Browse the repository at this point in the history
* Viximo/ci-sleep-patch:
  Add support for sleep_delay command line option
  Changed @@sleep_delay to self.class.sleep_delay to be consistent with other class variable usage
  • Loading branch information
bkeepers committed Sep 27, 2010
2 parents 4a98683 + 34fc406 commit aba9905
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/delayed/command.rb
Expand Up @@ -44,8 +44,9 @@ def initialize(args)
opts.on('-m', '--monitor', 'Start monitor process.') do
@monitor = true
end


opts.on('--sleep-delay N', "Amount of time to sleep when no jobs are found") do |n|
@options[:sleep_delay] = n
end
end
@args = opts.parse!(args)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/delayed/worker.rb
Expand Up @@ -45,6 +45,7 @@ def initialize(options={})
@quiet = options.has_key?(:quiet) ? options[:quiet] : true
self.class.min_priority = options[:min_priority] if options.has_key?(:min_priority)
self.class.max_priority = options[:max_priority] if options.has_key?(:max_priority)
self.class.sleep_delay = options[:sleep_delay] if options.has_key?(:sleep_delay)
end

# Every worker has a unique name which by default is the pid of the process. There are some
Expand Down Expand Up @@ -80,7 +81,7 @@ def start
break if $exit

if count.zero?
sleep(@@sleep_delay)
sleep(self.class.sleep_delay)
else
say "#{count} jobs processed at %.4f j/s, %d failed ..." % [count / realtime, result.last]
end
Expand Down

0 comments on commit aba9905

Please sign in to comment.