开发者

Getting async http requests to work on rails 3beta4/ruby 1.9.2-rc2/thin/eventmachine

开发者 https://www.devze.com 2023-01-08 17:01 出处:网络
I\'ve been trying to get basic async HTTP calls to work in my app. I\'ve tried using some codein my app from the Rails 3 async stack demo: http://github.com/igrigorik/async-rails, but I\'m getting \"

I've been trying to get basic async HTTP calls to work in my app.

I've tried using some code in my app from the Rails 3 async stack demo: http://github.com/igrigorik/async-rails, but I'm getting "can't yield from root fiber" and I have no idea where to go from here. He开发者_如何学Cre's the top of my trace:

(eval):10:in `yield'
(eval):10:in `get'
app/controllers/home_controller.rb:62:in `index'
/Users/ct/.rvm/gems/ruby-1.9.2-rc2@og/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/Users/ct/.rvm/gems/ruby-1.9.2-rc2@og/gems/actionpack-3.0.0.beta4/lib/abstract_controller/base.rb:145:in `process_action'

my index controller method is simply:

def index
  http = EM::HttpRequest.new("http://www.google.com/").get
  render :text => http.response
end

I've got all the right gems, I've got 1.9.2-rc2, rails 3 beta 4, and I'm running thin. I also got the async-rails app itself to run fine using the same rvm and gemset. The eventmachine reactor is definitely running in my app. I'd love any hints about how to get this working properly!

0

精彩评论

暂无评论...
验证码 换一张
取 消