Top Level Namespace

Defined Under Namespace

Modules: Rbundle Classes: RBundler

Instance Method Summary collapse

Instance Method Details

#with_retries(retries = 3, back_off = 60, args, &block) ⇒ Object



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

def with_retries(retries = 3, back_off = 60, args,  &block)
  counter = 1
  until counter > retries do
    begin
      block.call(*args)
      break
    rescue Exception => e
      raise e if counter == retries
      counter = counter + 1
      p "Sleeping #{counter * back_off} seconds"
      sleep counter * back_off;
    end
  end
end