Is it possible to initiate multiple parallel http requests using EventMachine with Ruby 1.8
问题 em-synchrony.rb implements this feature with Fibers but I would go for a non-Fibre version with 1.8 MRI. EM.run do http = EM::Protocols::HttpClient2.connect("www.google.com", 80) request = http.get("/") request.callback do puts request.status EM.stop end end 回答1: Have a look at em-http-request: EM.run do http1 = EventMachine::HttpRequest.new('http://example.com/1').get http1.callback do p http1.response end http2 = EventMachine::HttpRequest.new('http://example.com/2').get http2.callback do p