'Wait until condition expression `cond` is True, up to `timeout` sec
Parameters
cond : callable
The expression to check condition
(should return equivalent to bool True if wait successful).
timeout : float or callable
The time out for end of wait
(in seconds or callable that returns True if timeout occurred).
interval : float (optional)
Polling start interval for wait cycle in seconds.
Returns
variable
The return value of the last call of `cond`,
logical False (or None, 0, etc) if timeout occurred.'

@staticmethod
def wait_for(cond, timeout, interval=None):

    ini = 1
    while True:
        ret = cond()
        if ret:
            return ret
        if ini:
            ini = stm = 0
            if (not callable(timeout)):
                time0 = (time.time() + timeout)
                timeout_expr = (lambda : (time.time() > time0))
            else:
                timeout_expr = timeout
            if (not interval):
                interval = Utils.DEFAULT_SLEEP_INTERVAL
        if timeout_expr():
            break
        stm = min((stm + interval), Utils.DEFAULT_SLEEP_TIME)
        time.sleep(stm)
    return ret
