Skip to content

Instantly share code, notes, and snippets.

View panzacoder's full-sized avatar

Jake Hebert panzacoder

  • Pensacola, FL
View GitHub Profile
@nathanl
nathanl / exponential_backoff.rb
Created February 25, 2015 14:41
Exponential backoff in Ruby
# Exponential backoff in Ruby
begin
make_request
rescue RequestError => e
if retries <= max_retries
retries += 1
sleep 2 ** retries
retry
else
raise "Timeout: #{e.message}"