Skip to content

Instantly share code, notes, and snippets.

@wuputah
Created August 10, 2010 02:20
Show Gist options
  • Save wuputah/516544 to your computer and use it in GitHub Desktop.
Save wuputah/516544 to your computer and use it in GitHub Desktop.
def retry_times(exception = StandardError, times = 3, &block)
yield
rescue Exception => e
if times <= 1 || !e.is_a?(exception)
raise
else
sleep(0.5)
retry_times(exception, times - 1, &block)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment