code: def wait_for(self, condition, timeout=None, interval=0.1, errmsg=None):
          '''Wait for a condition to be True.
  
          Wait for condition, a callable, to return True.  If timeout is
          nonzero, raise a TimeoutError(errmsg) if the condition is not
          True after timeout seconds.  Check the condition everal
          interval seconds.
          '''
  
          t0 = time.time()
          while not condition():
              t1 = time.time()
              if timeout and (t1 - t0) >= timeout:
                  raise TimeoutError(errmsg)
  
              time.sleep(intervalf wait_for(self, condition, timeout=None, interval=0.1, errmsg=None):
          '''Wait for a condition to be True.
  
          Wait for condition, a callable, to return True.  If timeout is
          nonzero, raise a TimeoutError(errmsg) if the condition is not
          True after timeout seconds.  Check the condition everal
          interval seconds.
          '''
  
          t0 = time.time()
          while not condition():
              t1 = time.time()
              if timeout and (t1 - t0) >= timeout:
                  raise TimeoutError(errmsg)
  
              time.sleep(interval)
docs: Wait for a condition to be True.
  
          Wait for condition, a callable, to return True.  If timeout is
          nonzero, raise a TimeoutError(errmsg) if the condition is not
          True after timeout seconds.  Check the condition everal
          interval seconds.