私は次のコードを持っている:async_sinatraのリクエストがem-httpで黙ってクラッシュします。これをどうやって解決するのですか?
require 'rubygems'
require 'eventmachine'
require 'em-http'
require 'sinatra/base'
require 'sinatra/async'
class Api < Sinatra::Base
register Sinatra::Async
aget '/1' do
EventMachine.run {
http = EventMachine::HttpRequest.new("http://www.google.com").get(:timeout => 5)
http.callback { puts "h2" ;ret_val = http.response; EventMachine.stop}
http.errback {puts "was h2ere1" ;ret_val = nil; EventMachine.stop}
}
body "done processing 1"
end
aget '/2' do
body "done processing 2"
end
end
私は次のように発行すると、それがうまく機能:
curl http://localhost:3000/2
をしかし、私は、次のリクエストを発行したとき、それは静かに「H2」、アプリケーションを出力します終了:
curl http://localhost:3000/1
助けていただければ幸いです。ありがとう!
申し訳ありません - これらのURLを確認できますか?同じURLを2回呼び出すと、動作が異なりますか? – stef
Stefがとても早く帰ってくれてありがとう!私が修正したコピー・ペースト・エラーがありました。 – Troy
そして、あなたは薄い/虹/ユニコーンの後ろでこれを走らせているのは明らかです。 – stef