code: def wait(self, cond, timeout=None):
          
  
          tic = time.time()
  
          if self._poll is None:
              if self._state is None:
                  self._state = self._attribute_file_open('state')
              self._poll = select.poll()
              self._poll.register(self._state, select.POLLPRI)
  
          # Set poll timeout to something small. For more details, see
          # https://github.com/ev3dev/ev3dev-lang-python/issues/583
          if timeout:
              poll_tm = min(timeout, 100)
          else:
              poll_tm = 100
  
          while True:
              # This check is now done every poll_tm even if poll has nothing to report:
              if cond(self.state):
                  return True
  
              self._poll.poll(poll_tm)
  
              if timeout is not None and time.time() >= tic + timeout / 1000:
                  # Final check when user timeout is reached
                  return cond(self.state)
docs: Blocks until ``cond(self.state)`` is ``True``.  The condition is
          checked when there is an I/O event related to the ``state`` attribute.
          Exits early when ``timeout`` (in milliseconds) is reached.
  
          Returns ``True`` if the condition is met, and ``False`` if the timeout
          is reached.