class Aws::Plugins::Retries::ClientRateLimiter

def token_bucket_acquire(amount, wait_to_fill = true)

def token_bucket_acquire(amount, wait_to_fill = true)
  # Client side throttling is not enabled until we see a
  # throttling error
  return unless @enabled
  @mutex.synchronize do
    token_bucket_refill
    # Next see if we have enough capacity for the requested amount
    while @current_capacity < amount
      raise Aws::Errors::RetryCapacityNotAvailableError unless wait_to_fill
      @mutex.sleep((amount - @current_capacity) / @fill_rate)
      token_bucket_refill
    end
    @current_capacity -= amount
  end
end