Last active
December 24, 2015 11:29
-
-
Save eswdd/6790843 to your computer and use it in GitHub Desktop.
Celluloid futures playing up?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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