Skip to content

Instantly share code, notes, and snippets.

@mgroebner
Last active December 23, 2015 04:09
Show Gist options
  • Save mgroebner/6578505 to your computer and use it in GitHub Desktop.
Save mgroebner/6578505 to your computer and use it in GitHub Desktop.
celluloid trap exit
require 'celluloid/autostart'
class Manager
include Celluloid
trap_exit :processor_died
def initialize
@ready = 2.times.map { Processor.new_link }
end
def start
@ready.each {|processor| processor.async.fetch}
end
def processor_died(processor, reason)
actor = Processor.new_link
actor.async.fetch
end
end
class Processor
include Celluloid
def fetch
raise "fatal errrror"
end
end
m = Manager.new
m.start
sleep
~/dev/tik/scripts » jruby celluloid_trap_exit_penetration.rb matt@mattnb
E, [2013-09-16T12:25:16.956000 #85997] ERROR -- : Processor crashed!
RuntimeError: fatal errrror
celluloid_trap_exit_penetration.rb:26:in `fetch'
org/jruby/RubyKernel.java:1932:in `public_send'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/calls.rb:25:in `dispatch'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/calls.rb:122:in `dispatch'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:322:in `handle_message'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:416:in `task'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks.rb:55:in `initialize'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks/task_fiber.rb:13:in `create'
E, [2013-09-16T12:25:16.956000 #85997] ERROR -- : Processor crashed!
RuntimeError: fatal errrror
celluloid_trap_exit_penetration.rb:26:in `fetch'
org/jruby/RubyKernel.java:1932:in `public_send'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/calls.rb:25:in `dispatch'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/calls.rb:122:in `dispatch'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:322:in `handle_message'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:416:in `task'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks.rb:55:in `initialize'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks/task_fiber.rb:13:in `create'
E, [2013-09-16T12:25:16.962000 #85997] ERROR -- : Manager crashed!
Celluloid::DeadTaskError: cannot resume a dead task (resuming fiber from different thread)
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks/task_fiber.rb:27:in `deliver'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks.rb:98:in `resume'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/responses.rb:11:in `dispatch'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:327:in `handle_message'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:174:in `run'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:157:in `initialize'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/thread_handle.rb:13:in `initialize'
org/jruby/RubyProc.java:255:in `call'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/internal_pool.rb:100:in `create'
W, [2013-09-16T12:25:16.963000 #85997] WARN -- : Terminating task: type=:exit_handler, meta={:method_name=>:processor_died}, status=:callwait
E, [2013-09-16T12:25:16.963000 #85997] ERROR -- : Processor crashed!
Celluloid::DeadTaskError: cannot resume a dead task (resuming fiber from different thread)
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks/task_fiber.rb:27:in `deliver'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks.rb:98:in `resume'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/responses.rb:11:in `dispatch'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:327:in `handle_message'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:174:in `run'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:157:in `initialize'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/thread_handle.rb:13:in `initialize'
org/jruby/RubyProc.java:255:in `call'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/internal_pool.rb:100:in `create'
E, [2013-09-16T12:25:16.963000 #85997] ERROR -- : Processor crashed!
Celluloid::DeadTaskError: cannot resume a dead task (resuming fiber from different thread)
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks/task_fiber.rb:27:in `deliver'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks.rb:98:in `resume'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/responses.rb:11:in `dispatch'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:327:in `handle_message'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:174:in `run'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:157:in `initialize'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/thread_handle.rb:13:in `initialize'
org/jruby/RubyProc.java:255:in `call'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/internal_pool.rb:100:in `create'
W, [2013-09-16T12:25:16.964000 #85997] WARN -- : Terminating task: type=:exit_handler, meta={:method_name=>:processor_died}, status=:callwait
E, [2013-09-16T12:25:16.966000 #85997] ERROR -- : Manager: CLEANUP CRASHED!
Celluloid::DeadTaskError: cannot resume a dead task (resuming fiber from different thread)
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks/task_fiber.rb:27:in `deliver'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks.rb:98:in `resume'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks.rb:124:in `terminate'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/tasks/task_fiber.rb:32:in `terminate'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:404:in `cleanup'
org/jruby/RubyArray.java:1617:in `each'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:404:in `cleanup'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:375:in `shutdown'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:367:in `handle_crash'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:187:in `run'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/actor.rb:157:in `initialize'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/thread_handle.rb:13:in `initialize'
org/jruby/RubyProc.java:255:in `call'
/Users/matt/.rvm/gems/jruby-1.7.4@tickaroo/gems/celluloid-0.15.1/lib/celluloid/internal_pool.rb:100:in `create'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment