def read_nonblocking(self, size=1, timeout=None):
    """Read, handling terminal control input from an HP ProCurve.

    This may or may not actually block, as per its parent.

    Args:
      size: An int, the minimum size block to return.
      timeout: An optional float, wait only timeout seconds at most.

    Returns:
      A string, the filtered output.
    """
    start = time.time()
    if timeout == -1:
      timeout = self.timeout
    while True:
      if timeout and time.time() > start + timeout:
        return ''
      in_data = SshSpawn.read_nonblocking(self, size=size, timeout=timeout)
      logging.vlog(4, 'Unfiltered: %r', in_data)
      if in_data and self._read_nonblocking_buf:
        logging.debug('Prepending data: %r', self._read_nonblocking_buf)
        in_data = self._read_nonblocking_buf + in_data
        self._read_nonblocking_buf = ''
      filtered = self._Filter(in_data)
      escape_location = filtered.find('\x1B')
      if escape_location != -1:
        logging.debug('Partial ANSI tag in filtered data: %r', filtered)
        self._read_nonblocking_buf = filtered[escape_location:]
        filtered = filtered[:escape_location]
      if filtered:
        return filtered
dataset/ETHPy150Open google/capirca/tools/ldpush/pexpect_connection.py/HpSshSpawn.read_nonblocking/original