让异步http请求在rails 3beta4/ruby 1.9.2-rc2/thin/eventmachine上工作

发布于 2024-09-10 09:27:52 字数 909 浏览 2 评论 0原文

我一直在尝试在我的应用程序中使用基本的异步 HTTP 调用。

我尝试在我的应用程序中使用 Rails 3 异步堆栈演示中的一些代码: http://github.com /igrigorik/async-rails,但我得到“无法从根纤维产生”,我不知道从这里去哪里。这是我的跟踪的顶部:

(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'

我的索引控制器方法很简单:

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

我有所有正确的 gem,我有 1.9.2-rc2,rails 3 beta 4,而且我正在运行。我还让 async-rails 应用程序本身使用相同的 rvm 和 gemset 运行良好。 eventmachine 反应器肯定在我的应用程序中运行。我希望得到有关如何使其正常工作的任何提示!

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. Here'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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文