Module: Resque::Plugins::WorkerTimeout

Defined in:
lib/resque/plugins/worker_timeout.rb

Instance Method Summary collapse

Instance Method Details

#around_perform(*args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/resque/plugins/worker_timeout.rb', line 13

def around_perform(*args)
  begin
    Timeout::timeout(timeout) do
      yield
    end
  rescue Timeout::Error => e
    if reenqueue_worker
      Resque.enqueue self, *args
    else
      raise e
    end
  end
end

#reenqueue_workerObject



9
10
11
# File 'lib/resque/plugins/worker_timeout.rb', line 9

def reenqueue_worker
  @reenqueue_worker || false
end

#timeoutObject



5
6
7
# File 'lib/resque/plugins/worker_timeout.rb', line 5

def timeout
  @timeout || 600
end