def try_until_succeed(_warning_period, func, *argv, **kwarg):
    """Try a function until it successfully returns.
    
    Print current exception every ``_warning_period`` times try.
    
    **中文文档**
    
    尝试一个函数直到其成功为止。不适用于会出现死循环的函数。
    
    每隔``_warning_period``次失败, 就会打印当前异常和尝试次数。
    """
    if (not isinstance(_warning_period, int)) or (_warning_period < 1):
        raise Exception("'_warning_period' argument has to be int "
                        "and greater than 0")
        
    counter = 1
    while 1:
        try:
            return func(*argv, **kwarg)
        except Exception as e:
            current_exception = e
            counter += 1
            if (counter % _warning_period) == 0:
                print("Warning: this is %sth try, current error is "
                      "%s" % (counter, repr(current_exception)))
Try a function until it successfully returns.
    
    Print current exception every ``_warning_period`` times try.
    
    **中文文档**
    
    尝试一个函数直到其成功为止。不适用于会出现死循环的函数。
    
    每隔``_warning_period``次失败, 就会打印当前异常和尝试次数。