Class: Celluloid::PoolManager

Inherits:
Object
  • Object
show all
Defined in:
lib/creeper/celluloid_ext.rb

Instance Method Summary collapse

Instance Method Details

#crash_handler(actor, reason) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/creeper/celluloid_ext.rb', line 31

def crash_handler(actor, reason)
  return unless reason # don't restart workers that exit cleanly
  index = @idle.rindex(actor) # replace the old actor if possible
  if index
    @idle[index] = @worker_class.new_link(*@args)
  else
    @idle << @worker_class.new_link(*@args)
  end
end

#execute(method, *args, &block) ⇒ Object

ensure that the provisioned worker is alive to prevent PoolManager from dying



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/creeper/celluloid_ext.rb', line 19

def execute(method, *args, &block)
  worker = provision_worker
  
  begin
    worker._send_ method, *args, &block
  rescue Celluloid::DeadActorError, Celluloid::MailboxError
    execute(method, *args, &block)
  ensure
    @idle << worker if worker && worker.alive?
  end
end