等待func为真,直到耗费指定时间
import time
#
# def wait_func(func):
#     def inner(*args, **kwargs):
#         ret = func(*args, **kwargs)
#         return ret
#     return inner
#
#
# @wait_func
# def  is_sucess(a):
#     return a >= 5
# print(is_sucess(6))
def wait(try_times, period, fun, *args, **kwargs):
    ret = fun(*args, **kwargs)
    while not ret  and try_times > 0:
        time.sleep(1)
        print("我睡了1s")
        ret = fun(*args, **kwargs)
        try_times -=1
    return ret
def get_five(a):
    return a >= 5
wait(10, 1, get_five, 1)