From: Tom Reilly Date: 2010-03-09T08:13:41+09:00 Subject: Re: asynchronous network access with Rack? I've used threading with getting several web pages for a long time and I've never had any problem so long as you catch errors if a specifc web page can't be obtained. Tom Reilly Nick Brown wrote: > I've read that "threading is considered harmful" for Ruby web apps. > Well, I'm writing a Sinatra app which will build a page based on the > responses of several servers (Net::HTTP.get). I want to do these .gets > in parallel, as doing them synchronously would obviously mean the users > would wait for a long time. > > Would it be "considered harmful" to do: > > resp_a, resp_b, resp_c = nil > thread_a = Thread.new { resp_a = Net::HTTP.get site_a } > thread_b = Thread.new { resp_b = Net::HTTP.get site_b } > thread_c = Thread.new { resp_c = Net::HTTP.get site_c } > thread_a.join > thread_b.join > thread_c.join > > Is there any possible harm that could come from this? Can threading > interfere with Rack in some way? I haven't done much previous > development of threaded apps, so I would appreciate any tips. >