From: Daniel N Date: 2010-05-19T08:27:29+09:00 Subject: Re: Asynchronous HTTP request --00504502ce959500850486e6abb0 Content-Type: text/plain; charset=ISO-8859-1 On 18 May 2010 16:56, Daniel DeLorme wrote: > Daniel N wrote: > >> On 13 May 2010 17:37, Daniel DeLorme wrote: >> >> Does anyone know how to do the following, but without threads, purely >>> with >>> asynchronous IO? >>> >>> website = Thread.new{ Net::HTTP.get(URI.parse(url)) } >>> template = compute_lots_of_stuff() >>> puts template.sub("", website.value) >>> >> >> Event machine is perfect for this kind of stuff. Weather it fits with the >> rest of your web framework is more likely the thing that makes it an >> unlikely selection (if you're using anything rack based for example) >> > > If you could show me how to use EventMachine in this case I'd be grateful. > I couldn't figure out how to run compute_lots_of_stuff() while the http > requests are executing. > 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? Cheers Daniel --00504502ce959500850486e6abb0--