code: def retries(timeout=30, intervals=1, time=time):
      
      start = time()
      end = start + timeout
  
      if isinstance(intervals, Iterable):
          intervals = iter(intervals)
      else:
          intervals = repeat(intervals)
  
      return gen_retries(start, end, intervals, time)
docs: Helper for retrying something, sleeping between attempts.
  
      Returns a generator that yields ``(elapsed, remaining, wait)`` tuples,
      giving times in seconds. The last item, `wait`, is the suggested amount of
      time to sleep before trying again.
  
      :param timeout: From now, how long to keep iterating, in seconds. This can
          be specified as a number, or as an iterable. In the latter case, the
          iterator is advanced each time an interval is needed. This allows for
          back-off strategies.
      :param intervals: The sleep between each iteration, in seconds, an an
          iterable from which to obtain intervals.
      :param time: A callable that returns the current time in seconds.