def delayed_retry_gen(delay_schedule=[.1, 1, 10], msg=None, timeout=None, raise_=True):
    """ template code for a infinte retry loop """
    import utool as ut
    import time
    if not ut.isiterable(delay_schedule):
        delay_schedule = [delay_schedule]
    tt = ut.tic()

    # First attempt is immediate
    yield 0

    for count in it.count(0):
        #print('count = %r' % (count,))
        if timeout is not None and ut.toc(tt) > timeout:
            if raise_:
                raise Exception('Retry loop timed out')
            else:
                raise StopIteration('Retry loop timed out')
        index = min(count, len(delay_schedule) - 1)
        delay = delay_schedule[index]
        time.sleep(delay)
        yield count + 1
template code for a infinte retry loop