Method: Fog::Compute::Google::Shared#backoff_if_unfound
- Defined in:
- lib/fog/google/compute.rb
#backoff_if_unfound(&block) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/fog/google/compute.rb', line 110 def backoff_if_unfound(&block) retries_remaining = 10 sleep_time = 0.1 begin result = block.call rescue Exception => msg if msg.to_s.include? 'was not found' and retries_remaining > 0 retries_remaining -= 1 sleep sleep_time sleep_time *= 1.6 retry else raise msg end end result end |