Class: S3Website::Retry

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_website/retry.rb

Class Method Summary collapse

Class Method Details

.run_with_retry(sleep_milliseconds = 3.000) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/s3_website/retry.rb', line 3

def self.run_with_retry(sleep_milliseconds = 3.000)
  attempt = 0
  begin
    yield
  rescue Exception => e
    $stderr.puts "Exception Occurred:  #{e.message} (#{e.class})  Retrying in 3 seconds..."
    sleep sleep_milliseconds
    attempt += 1
    if attempt <= 3
      retry
    else
      raise RetryAttemptsExhaustedError
    end
  end
end