Class: Jekyll::S3::Retry

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-s3/retry.rb

Class Method Summary collapse

Class Method Details

.run_with_retry(sleep_milliseconds = 3.000) ⇒ Object



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

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