Permalink
Browse files

retry

  • Loading branch information...
sorah committed Oct 31, 2015
1 parent af22acf commit 39c1a739086ebccfb5f6075a85b72875be938551
Showing with 14 additions and 3 deletions.
  1. +14 −3 5f/webapp/ruby/app.rb
View
@@ -189,13 +189,24 @@ def fetch_http(headers, params, call_uri, conf)
raise "unknown method #{method}"
end
s = Time.now
res = @client.request(call_uri, req)
e = Time.now
retried = false
begin
s = Time.now
res = @client.request(call_uri, req)
e = Time.now
res.value
rescue Exception => err
e ||= Time.now
s ||= Time.now
if res && res.code == '429' && !retried
retried = true
$stderr.puts "[API CALL][HTTP][RETRY] #{method} #{call_uri} (#{"%.2f" % (e-s)}s, #{err.inspect}) #{headers.inspect}"
retry
sleep 1
end
$stderr.puts "[API CALL][HTTP][ERROR] #{method} #{call_uri} (#{"%.2f" % (e-s)}s, #{err.inspect}) #{headers.inspect}"
raise
end

0 comments on commit 39c1a73

Please sign in to comment.