secret
Last active

After adding Fiber#backtrace to rbx, we can see what each Fiber is doing!!

  • Download Gist
amazing-celluloid-stack-dumps.md
Markdown

1 second has elapsed.

  • The Actor thread is delivering the SyncCall message to the Task.
  • The sleeping Task will be resumed in 2 seconds.
  • The running Task (which is blocking using Kernel.sleep) will return in 1 second.
dump.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
Celluloid::Actor 0x7400: Waiter
State: Running (executing tasks)
gems/celluloid/lib/celluloid/tasks/task_fiber.rb:19:in `deliver'
gems/celluloid/lib/celluloid/tasks.rb:69:in `resume'
gems/celluloid/lib/celluloid/actor.rb:0:in `task'
gems/celluloid/lib/celluloid/actor.rb:317:in `handle_message'
gems/celluloid/lib/celluloid/actor.rb:174:in `run'
gems/celluloid/lib/celluloid/actor.rb:157:in `initialize'
gems/celluloid/lib/celluloid/thread_handle.rb:12:in `initialize'
gems/celluloid/lib/celluloid/internal_pool.rb:63:in `create'
 
Tasks:
1) Celluloid::TaskFiber: sleeping
gems/celluloid/lib/celluloid/tasks/task_fiber.rb:14:in `signal'
gems/celluloid/lib/celluloid/tasks.rb:59:in `suspend'
gems/celluloid/lib/celluloid/tasks.rb:19:in `suspend'
gems/celluloid/lib/celluloid.rb:60:in `suspend'
gems/celluloid/lib/celluloid/actor.rb:308:in `sleep'
gems/celluloid/lib/celluloid.rb:443:in `sleep'
(pry):1:in `wait'
gems/celluloid/lib/celluloid/calls.rb:25:in `dispatch'
gems/celluloid/lib/celluloid/calls.rb:125:in `dispatch'
gems/celluloid/lib/celluloid/actor.rb:326:in `handle_message'
gems/celluloid/lib/celluloid/tasks.rb:42:in `initialize'
gems/celluloid/lib/celluloid/tasks/task_fiber.rb:9:in `create'
 
2) Celluloid::TaskFiber: running
(pry):1:in `block'
gems/celluloid/lib/celluloid/calls.rb:25:in `dispatch'
gems/celluloid/lib/celluloid/calls.rb:125:in `dispatch'
gems/celluloid/lib/celluloid/actor.rb:326:in `handle_message'
gems/celluloid/lib/celluloid/tasks.rb:42:in `initialize'
gems/celluloid/lib/celluloid/tasks/task_fiber.rb:9:in `create'
 
Fiber 0x73f8:
gems/celluloid/lib/celluloid/stack_dump.rb:53:in `snapshot_thread'
gems/celluloid/lib/celluloid/stack_dump.rb:30:in `snapshot'
gems/celluloid/lib/celluloid/stack_dump.rb:26:in `snapshot'
gems/celluloid/lib/celluloid/stack_dump.rb:22:in `initialize'
gems/celluloid/lib/celluloid.rb:47:in `dump'
(pry):1:in `__pry__'
rbx/gems/1.9/gems/pry-0.9.12/lib/pry/pry_instance.rb:328:in `evaluate_ruby'
rbx/gems/1.9/gems/pry-0.9.12/lib/pry/pry_instance.rb:278:in `re'
rbx/gems/1.9/gems/pry-0.9.12/lib/pry/pry_instance.rb:254:in `rep'
rbx/gems/1.9/gems/pry-0.9.12/lib/pry/pry_instance.rb:234:in `repl'
rbx/gems/1.9/gems/pry-0.9.12/lib/pry/pry_instance.rb:232:in `repl'
rbx/gems/1.9/gems/pry-0.9.12/lib/pry/pry_instance.rb:231:in `repl'
rbx/gems/1.9/gems/pry-0.9.12/lib/pry/pry_instance.rb:230:in `repl'
rbx/gems/1.9/gems/pry-0.9.12/lib/pry/pry_class.rb:170:in `start'
rbx/gems/1.9/gems/pry-0.9.12/lib/pry/cli.rb:201:in `__script__'
rbx/gems/1.9/gems/pry-0.9.12/lib/pry/cli.rb:70:in `parse_options'
rbx/gems/1.9/gems/pry-0.9.12/lib/pry/cli.rb:70:in `parse_options'
rbx/gems/1.9/gems/pry-0.9.12/bin/pry:16:in `__script__'
rbx/gems/1.9/bin/pry:23:in `__script__'
 
Fiber 0x73fc:
rbx/lib/19/timeout.rb:90:in `watch_channel'
rbx/lib/19/timeout.rb:125:in `Timeout'
waiter.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
class Waiter
include Celluloid
def wait
sleep 3
end
def block
Kernel.sleep(2)
end
end
 
w = Waiter.new
w.async.wait
w.async.block
sleep 1
Celluloid.dump

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.