Skip to content

Instantly share code, notes, and snippets.

@heftig
Created October 15, 2011 21:19
Show Gist options
  • Save heftig/1290166 to your computer and use it in GitHub Desktop.
Save heftig/1290166 to your computer and use it in GitHub Desktop.
# Need to block
begin
json = Timeout.timeout 3 do
Net::HTTP.new(uri.host, uri.port).start do |https|
https.request_get(uri.request_uri)
end
end
rescue Timeout::Error
if @retries >= 3
return {return: 'Gateway Timeout.', response: 504}
end
@retries+=1
sleep(1)
retry # Don't flood them.
end
# Need to block
# When I run the method it just keeps going and below this it tries to parse the JSON but errors out with NameError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment