Skip to content

Commit

Permalink
More whitespace cleaning.
Browse files Browse the repository at this point in the history
  • Loading branch information
bryckbost committed Sep 28, 2011
1 parent 6c22be3 commit 2b0d28d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/delayed/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
require 'logger'

module Delayed
class Worker
class Worker
cattr_accessor :min_priority, :max_priority, :max_attempts, :max_run_time, :default_priority, :sleep_delay, :logger, :delay_jobs, :queues
self.sleep_delay = 5
self.max_attempts = 25
self.max_run_time = 4.hours
self.default_priority = 0
self.delay_jobs = true
self.queues = []

# Add or remove plugins in this list before the worker is instantiated
cattr_accessor :plugins
self.plugins = [Delayed::Plugins::ClearLocks]
Expand Down Expand Up @@ -45,7 +45,7 @@ def self.backend=(backend)
end

def self.guess_backend
warn "[DEPRECATION] guess_backend is deprecated. Please remove it from your code."
warn "[DEPRECATION] guess_backend is deprecated. Please remove it from your code."
end

def self.before_fork
Expand All @@ -55,11 +55,11 @@ def self.before_fork
@files_to_reopen << file unless file.closed?
end
end

backend.before_fork
end
def self.after_fork

def self.after_fork
# Re-open file handles
@files_to_reopen.each do |file|
begin
Expand All @@ -68,10 +68,10 @@ def self.after_fork
rescue ::Exception
end
end

backend.after_fork
end

def self.lifecycle
@lifecycle ||= Delayed::Lifecycle.new
end
Expand All @@ -82,7 +82,7 @@ def initialize(options={})
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)
self.class.queues = options[:queues] if options.has_key?(:queues)

self.plugins.each { |klass| klass.new }
end

Expand All @@ -100,13 +100,13 @@ def name
def name=(val)
@name = val
end

def start
trap('TERM') { say 'Exiting...'; stop }
trap('INT') { say 'Exiting...'; stop }

say "Starting job worker"

self.class.lifecycle.run_callbacks(:execute, self) do
loop do
self.class.lifecycle.run_callbacks(:loop, self) do
Expand All @@ -126,7 +126,7 @@ def start
say "#{count} jobs processed at %.4f j/s, %d failed ..." % [count / realtime, result.last]
end
end

break if @exit
end
end
Expand All @@ -135,7 +135,7 @@ def start
def stop
@exit = true
end

# Do num jobs and return stats on success/failure.
# Exit early if interrupted.
def work_off(num = 100)
Expand Down

0 comments on commit 2b0d28d

Please sign in to comment.