📜  等待函数python代码示例

📅  最后修改于: 2022-03-11 14:45:38.543000             🧑  作者: Mango

代码示例6
import time

def wait_until(somepredicate, timeout, period=0.25, *args, **kwargs):
  mustend = time.time() + timeout
  while time.time() < mustend:
    if somepredicate(*args, **kwargs): return True
    time.sleep(period)
  return False