From: Joel VanderWerf Date: 2009-09-11T02:54:18+09:00 Subject: Re: Asynchronous http POST? Ezra Zygmuntowicz wrote: > > On Sep 9, 2009, at 10:15 PM, Ivan Shevanski wrote: > >> Hey everyone, I'm new to Ruby and to the mailing list, so go easy. >> Basically, I have to POST to a certain url, then I wait for a response. >> The catch is that I have to do this to two urls at once. Both of them >> may respond to me almost instantly, or they may take up to 10 seconds to >> respond. I need to have a post to both of these running at all times to >> catch incoming events. I will also need to post to other urls at the >> same time that these are running. So, I need to find a way to run these >> two posts in the background constantly. From what I've read, ruby >> threads will hang on a command like this, since the interpreter does not >> have control. Can anyone help (or understand) me? >> >> Thanks, >> Ivan >> -- >> Posted via http://www.ruby-forum.com/. >> > > > > Ivan- > > This is a perfect job for eventmachine and em-http-request. You can > run as many async http requests as you want without blocking and handle > the results with callback blocks. In small scale cases (such as a simple client) is there any reason not to use threads? EM just seems like overkill for a fairly simple client. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407