Skip to content

Instantly share code, notes, and snippets.

@Sija
Last active February 16, 2018 02:41
Show Gist options
  • Select an option

  • Save Sija/63759198cdebf5f000a18e99f37e5f1d to your computer and use it in GitHub Desktop.

Select an option

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