Are rails timers reliable when using Net::HTTP?

Posted by Frank on Stack Overflow See other posts from Stack Overflow or by Frank
Published on 2010-03-11T20:07:41Z Indexed on 2010/03/11 20:09 UTC
Read the original article Hit count: 346

Filed under:
|
|
|

Hi All. When reading data from a potentially slow website, I want to ensure that get_response can not hang, and so added a timer to timeout after x seconds. So far, so good. I then read http://ph7spot.com/musings/system-timer which illustrates that in certain situations timer.rb doesn't work due to ruby's implementation of threads.

Does anyone know if this is one of these situations?

url = URI.parse(someurl)

begin Timeout::timeout(30) do response = Net::HTTP.get_response(url) @responseValue = CGI.unescape(response.body) end rescue Exception => e dosomething end

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about http