Skip to content

Instantly share code, notes, and snippets.

@shotat
Created September 18, 2016 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shotat/9f2978f5f549755822d40c3f0344b173 to your computer and use it in GitHub Desktop.
Save shotat/9f2978f5f549755822d40c3f0344b173 to your computer and use it in GitHub Desktop.
retry.rb
retries = 0
begin
service.update(record)
rescue VendorDeadlockError => e
raise if retries >= 3
retries += 1
logger.warn("API failure: #{e}, retrying...")
sleep(5**retries)
retry
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment