Skip to content

Instantly share code, notes, and snippets.

@eswdd
Last active December 24, 2015 11:29
Show Gist options
  • Save eswdd/6790843 to your computer and use it in GitHub Desktop.
Save eswdd/6790843 to your computer and use it in GitHub Desktop.
Celluloid futures playing up?
require 'celluloid'
require 'celluloid/future'
def pusher(future)
sleep 5
future.signal 'Wibble'
end
def puller(future)
puts "Pulled: #{future.value}"
end
future = Celluloid::Future.new
t1 = Thread.new {
begin
puller(future)
rescue Exception => e
puts "Exception raised: #{e.message}\n #{e.backtrace.join("\n ")}"
end
}
t2 = Thread.new {
begin
pusher(future)
rescue Exception => e
puts "Exception raised: #{e.message}\n #{e.backtrace.join("\n ")}"
end
}
t1.join
t2.join
%%
Output:
/usr/bin/ruby1.9.3 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/langfords/Dropbox/work/clouddeploy/src/future_sample.rb
Exception raised: undefined method `value' for "Wibble":String
/home/langfords/.gem/ruby/1.9.1/gems/celluloid-0.15.1/lib/celluloid/future.rb:104:in `value'
/home/langfords/.gem/ruby/1.9.1/gems/celluloid-0.15.1/lib/celluloid/future.rb:68:in `value'
/home/langfords/Dropbox/work/clouddeploy/src/future_sample.rb:10:in `puller'
/home/langfords/Dropbox/work/clouddeploy/src/future_sample.rb:17:in `block in <top (required)>'
%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment