Skip to content

Instantly share code, notes, and snippets.

@Sija
Last active February 16, 2018 02:41
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 Sija/63759198cdebf5f000a18e99f37e5f1d to your computer and use it in GitHub Desktop.
Save Sija/63759198cdebf5f000a18e99f37e5f1d to your computer and use it in GitHub Desktop.
def retry(limit, *, backoff = nil)
attempts = 1
loop do
return yield
rescue error
raise error if attempts == limit
sleep(backoff * attempts) if backoff
attempts += 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment