Created
September 18, 2016 10:24
-
-
Save shotat/9f2978f5f549755822d40c3f0344b173 to your computer and use it in GitHub Desktop.
retry.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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