Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
146 views
in Technique[技术] by (71.8m points)

Nested asynchronous processing with celluloid ruby gem

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...