mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #2474 from anl/gce-exponential-backoff
[google|compute] Add exponential backoff to Google Compute Engine's backoff_if_unfound.
This commit is contained in:
commit
c5e6e2ae86
1 changed files with 3 additions and 1 deletions
|
@ -99,12 +99,14 @@ module Fog
|
|||
|
||||
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 0.1
|
||||
sleep sleep_time
|
||||
sleep_time *= 1.6
|
||||
retry
|
||||
else
|
||||
raise msg
|
||||
|
|
Loading…
Reference in a new issue