瘦服务器基于EventMachine,因此我无法从EM.synchrony块中阻止它。 但在这种情况下,输出为:2,1,但不是1,2。我该如何解决?
EM.synchrony do
update_ads ads_hash, invalid_ads, ip, params, user_agent, request
EM::Synchrony::FiberIterator.new([1,2,3]).each do |i|
# some http requests
end
puts "1"
# EventMachine.stop
end
puts "2"
感谢您提前!
答案 0 :(得分:2)
EM.synchrony
块内。
<强> UPD 强>:
x = EM.synchrony do
# update_ads ads_hash, invalid_ads, ip, params, user_agent, request
EM::Synchrony::FiberIterator.new([1,2,3]).each do |i|
# some http requests
end
"1"
end
puts x
puts "2"