Concurrent web requests with Ruby (Sinatra?)?

Posted by cbmeeks on Stack Overflow See other posts from Stack Overflow or by cbmeeks
Published on 2010-04-26T13:24:32Z Indexed on 2010/04/26 15:13 UTC
Read the original article Hit count: 348

I have a Sinatra app that basically takes some input values and then finds data matching those values from external services like Flickr, Twitter, etc.

For example:

input:"Chattanooga Choo Choo" Would go out and find images at Flickr on the Chattanooga Choo Choo and tweets from Twitter, etc.

Right now I have something like:

@images = Flickr::...find...images..

@tweets = Twitter::...find...tweets...

@results << @images

@results << @tweets

So my question is, is there an efficient way in Ruby to run those requests concurrently? Instead of waiting for the images to finish before the tweets finish.

Thanks.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about sinatra