I am trying nested asynchronous processing with Celluloid ruby gem as bellow
class A
include Celluloid
def sum(num1, num2)
num1 + num2
end
end
class B
include Celluloid
def process
[[5,5], [10, 10]].map do |pair|
A.new.future.sum(pair[0], pair[1])
end.map(&:value).inject(:+)
end
end
Inside the controller we have
value = B.new.future.process.value
This works fine in the rails console but not in the controller.
Note: It works fine even in the controller in case I apply binding.pry
and run B.new.future.process.value
. If I hit the route directly it never returns a result and remains stuck forver.
question from:
https://stackoverflow.com/questions/66063278/nested-asynchronous-processing-with-celluloid-ruby-gem 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…