Daniel N wrote:
website = Thread.new{ Net::HTTP.get(URI.parse(url)) }
What context are you trying to do this in? Is it inside a rack request
(rails / merb / sinatra /pancake / other)? or is this in a stand alone
script?Could you perhaps provide a bit of context for what you’re trying to achive?
Ok, here’s the context. I didn’t put this in my OP because I figured
it would just bore everybody to tears.
This is inside a rack request. The idea is that I’m assembling a web
page by doing a bunch of sub-requests for the various parts of the
page. So I’ll have something like:
action “index” do
@news = subreq(“http://news.server”)
@ad = subreq(“http://ad.server”)
@blog = subreq(“http://blog.server”)
@forum = subreq(“http://forum.server”)
end
All these sub-requests are launched asynchronously and, while they are
executing, the app generates the layout within which the output of the
subrequests will be embedded. So I’ll have something like:
response = [‘’,
‘
‘
‘
‘
‘’]
And when rack finally outputs the response to the client it will block
on the various subrequests unless/until they have completed.
What I can’t figure out with EventMachine is how to have the “main
thread” generate the layout while the subrequests are executing.