Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote branch 'Viximo/ci-sleep-patch'

* 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...
commit aba9905764c2a13a110a272137d1ad9798fd55e0 2 parents 4a98683 + 34fc406
@bkeepers bkeepers authored
Showing with 5 additions and 3 deletions.
  1. +3 −2 lib/delayed/command.rb
  2. +2 −1  lib/delayed/worker.rb
View
5 lib/delayed/command.rb
@@ -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
View
3  lib/delayed/worker.rb
@@ -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
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.