def poll_until(predicate, steps, sleep=None):
 if (sleep is None):
  sleep = time.sleep
 for step in steps:
  result = predicate()
  if result:
   return result
  sleep(step)
 result = predicate()
 if result:
  return result
 raise LoopExceeded(predicate, result)

def poll_until ( predicate , steps , sleep = None ) : if ( sleep is None ) : sleep = time . sleep for step in steps : result = predicate ( ) if result : return result sleep ( step ) result = predicate ( ) if result : return result raise LoopExceeded ( predicate , result )
perform steps until a non-false result is returned .