mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
DEV-161796 Add jitter to exponential backoff.
This commit is contained in:
parent
e36bccc208
commit
e562fab0f9
1 changed files with 10 additions and 1 deletions
|
@ -560,7 +560,16 @@ module Fog
|
|||
Fog::Compute::AWS::NotFound.slurp(error, match[:message])
|
||||
when 'RequestLimitExceeded'
|
||||
if retries < max_retries
|
||||
sleep (2.0 ** (1.0 + retries) * 100) / 1000.0
|
||||
jitter = rand(100)
|
||||
waiting = true
|
||||
start_time = Time.now
|
||||
wait_time = ((2.0 ** (1.0 + retries) * 100) + jitter) / 1000.0
|
||||
puts "Waiting #{wait_time} seconds to retry."
|
||||
while waiting
|
||||
if Time.now - start_time >= wait_time
|
||||
waiting = false
|
||||
end
|
||||
end
|
||||
retries += 1
|
||||
retry
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue