0

我在带有 Rails 3.0.2 的 JRuby 1.6.7 上运行。我有一些调用 REST 服务的方法。

最好同时执行它们,而不是每个需要 2 秒才能返回总共 6 秒。我会在大约 2 秒内取回数据。

我不能使用 Fibers,因为以下调用使用阻塞 io 并且无法修改,因此我无法将它们编码为“合作”工作。我正在尝试使用抢先线程。

我在线程中有一个简单的调用,如下所示。

Thread.new do
  callrest1() 
end

虽然当此代码在线程内执行时出现以下错误。我猜它找不到正确的文件/类,因为它在一个新线程中?有任何想法吗?

预期 /home/joe/ruby/analysis/app/models/dashboard/reports.rb 来定义 Dashboard::Reports Rails.root: /home/joe/ruby/analysis

Application Trace | Framework Trace | Full Trace
activesupport (3.0.5) lib/active_support/dependencies.rb:492:in `load_missing_constant'
activesupport (3.0.5) lib/active_support/dependencies.rb:183:in `const_missing'
                      org/jruby/RubyArray.java:1615:in `each'
activesupport (3.0.5) lib/active_support/dependencies.rb:181:in `const_missing'
activesupport (3.0.5) lib/active_support/dependencies.rb:503:in `load_missing_constant'
activesupport (3.0.5) lib/active_support/dependencies.rb:183:in `const_missing'
                      org/jruby/RubyArray.java:1615:in `each'
activesupport (3.0.5) lib/active_support/dependencies.rb:181:in `const_missing'
                      app/controllers/dashboard/index_controller.rb:297:in `generateReport'
                      app/controllers/dashboard/index_controller.rb:223:in `index'
4

0 回答 0