This is an asyncio adapted version of pyserial read.
        It provides a non-blocking read and returns a line of data read.

        :return: A line of data
176926
async def readline(self):
        
        future = asyncio.Future()
        data_available = False
        while True:
            if not data_available:
                if not self.my_serial.inWaiting():
                    await asyncio.sleep(self.sleep_tune)
                else:
                    data_available = True
                    data = self.my_serial.readline()
                    future.set_result(data)
            else:
                if not future.done():
                    await asyncio.sleep(self.sleep_tune)
                else:
                    return future.result()
708454
def readline(self, timeout=1):
        
        tries = 0
        while 1:
            try:
                block = self.read(512)
                if isinstance(block, bytes):
                    block = block.decode()
                elif isinstance(block, str):
                    block = block.decode()
                else:
                    raise ValueError("Unknown data")
            except SerialTimeoutException:
                # Exception that is raised on write timeouts.
                block = ''
            except SerialException:
                # In case the device can not be found or can not be configured.
                block = ''
            except ValueError:
                # Will be raised when parameter are out of range, e.g. baud rate, data bits.
                # UnicodeError-Raised when a Unicode-related encoding or
                # decoding error occurs. It is a subclass of ValueError.
                block = ''
            with self.buffer_lock:
                # Let's lock, just in case
                self.buf += block
                pos = self.buf.find('\n')
                if pos >= 0:
                    line, self.buf = self.buf[:pos+1], self.buf[pos+1:]
                    return line
            tries += 1
            if tries * self.timeout > timeout:
                break
        return None
1099680
def read(self, timeout=1.0):
        """"""
        self.ser.timeout = timeout
        if self.ser is None:
            return ''
        return self.ser.readline()
96347
def read(self, mode='r', *, buffering=-1, encoding=None, newline=None):
        '''  '''
        with self.open(mode=mode, buffering=buffering, encoding=encoding, newline=newline) as fp:
            return fp.read()
1192873
def readline(self):
        
        buf = []
        while 1:
            try:
                ch = self.read(1)
            except EOFError:
                return ''.join(buf)
            buf.append(ch)
            if ch == '\n':
                return ''.join(buf)
140673
def read(self):
        
        if not self.fname:
            return
        try:
            with open(self.fname, "r") as f:
                wpid = int(f.read() or 0)
                if wpid <= 0:
                    return
                return wpid
        except IOError:
            return
841739
def readall(self):
        # type: () -> bytes
        '''
        
        '''
        if not self._open:
            raise pycdlibexception.PyCdlibInvalidInput('I/O operation on closed file.')

        readsize = self._length - self._offset
        if readsize > 0:
            data = self._fp.read(readsize)
            self._offset += readsize
        else:
            data = b''

        return data
1296474
def read(self, size=None):
        
        data = self.rfile.read(size)
        self.bytes_read += len(data)
        self._check_length()
        return data
1192737
async def read_line(stream: asyncio.StreamReader) -> bytes:
    
    # Security: this is bounded by the StreamReader's limit (default = 32 KiB).
    line = await stream.readline()
    # Security: this guarantees header values are small (hard-coded = 4 KiB)
    if len(line) > MAX_LINE:
        raise ValueError("Line too long")
    # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5
    if not line.endswith(b"\r\n"):
        raise ValueError("Line without CRLF")
    return line[:-2]
637231
def read(self, n):
        
        buf = self._read_buf
        pos = self._read_pos
        end = pos + n

        if end <= len(buf):
            # Fast path: the data to read is fully buffered.
            self._read_pos += n
            return self._update_pos(buf[pos:end])

        # Slow path: read from the stream until enough bytes are read,
        # or until an EOF occurs or until read() would block.
        wanted = max(self.buffer_size, n)
        while len(buf) < end:
            chunk = self.raw.read(wanted)
            if not chunk:
                break
            buf += chunk

        self._read_buf = buf[end:]  # Save the extra data in the buffer.
        self._read_pos = 0
        return self._update_pos(buf[pos:end])
471163
def read_io(io)
      data = ""

      while true
        begin
          if Platform.windows?
            # Windows doesn't support non-blocking reads on
            # file descriptors or pipes so we have to get
            # a bit more creative.

            # Check if data is actually ready on this IO device.
            # We have to do this since `readpartial` will actually block
            # until data is available, which can cause blocking forever
            # in some cases.
            results = IO.select([io], nil, nil, 0.1)
            break if !results || results[0].empty?

            # Read!
            data << io.readpartial(READ_CHUNK_SIZE)
          else
            # Do a simple non-blocking read on the IO object
            data << io.read_nonblock(READ_CHUNK_SIZE)
          end
        rescue Exception => e
          # The catch-all rescue here is to support multiple Ruby versions,
          # since we use some Ruby 1.9 specific exceptions.

          breakable = false

          # EOFError from OSX, EIO is raised by ubuntu
          if e.is_a?(EOFError) || e.is_a?(Errno::EIO)
            # An `EOFError` means this IO object is done!
            breakable = true
          elsif defined?(IO::WaitReadable) && e.is_a?(IO::WaitReadable)
            # IO::WaitReadable is only available on Ruby 1.9+

            # An IO::WaitReadable means there may be more IO but this
            # IO object is not ready to be read from yet. No problem,
            # we read as much as we can, so we break.
            breakable = true
          elsif e.is_a?(Errno::EAGAIN) || e.is_a?(Errno::EWOULDBLOCK)
            # Otherwise, we just look for the EAGAIN error which should be
            # all that IO::WaitReadable does in Ruby 1.9.
            breakable = true
          end

          # Break out if we're supposed to. Otherwise re-raise the error
          # because it is a real problem.
          break if breakable
          raise
        end
      end

      data
    end
757019
def read(self):
        ""
        if self.verbose > 1:
            sys.stderr.write("poll: reading from daemon...\n")
        eol = self.linebuffer.find('\n')
        if eol == -1:
            frag = self.sock.recv(4096)
            self.linebuffer += frag
            if self.verbose > 1:
                sys.stderr.write("poll: read complete.\n")
            if not self.linebuffer:
                if self.verbose > 1:
                    sys.stderr.write("poll: returning -1.\n")
                # Read failed
                return -1
            eol = self.linebuffer.find('\n')
            if eol == -1:
                if self.verbose > 1:
                    sys.stderr.write("poll: returning 0.\n")
                # Read succeeded, but only got a fragment
                return 0
        else:
            if self.verbose > 1:
                sys.stderr.write("poll: fetching from buffer.\n")

        # We got a line
        eol += 1
        self.response = self.linebuffer[:eol]
        self.linebuffer = self.linebuffer[eol:]

        # Can happen if daemon terminates while we're reading.
        if not self.response:
            return -1
        if self.verbose:
            sys.stderr.write("poll: data is %s\n" % repr(self.response))
        self.received = time.time()
        # We got a \n-terminated line
        return len(self.response)
1204431
def _read_message(self):
        
        line = self._rfile.readline()

        if not line:
            return None

        content_length = self._content_length(line)

        # Blindly consume all header lines
        while line and line.strip():
            line = self._rfile.readline()

        if not line:
            return None

        # Grab the body
        return self._rfile.read(content_length)
602124
def _read(self):
        
        raw_response = self.transport.receive()
        response = Packet.parse(raw_response)

        # FIXME
        if response.response_type == Packet.EVENT and response.event_type == "log":
            # queue up any debug log messages, and get next
            self.log_events.append(response)
            # do something?
            self._read()
        else:
            return response
384148
def sync(self):
        
        if self._sync is None:
            from twilio.rest.sync import Sync
            self._sync = Sync(self)
        return self._sync
423332
def read_loop
      loop do
        unless @options.fetch(:device)
          sleep 0.1
          next
        end
        begin
          raw_data, = raw_socket.recvfrom(8192)
          udp = Pio::Udp.read(raw_data)
          next if @stop
          unless @options[:promisc]
            next if udp.destination_ip_address != @options.fetch(:ip_address)
          end
          @logger.info "Received: #{udp}"
          @packets_received << udp.snapshot
        rescue Errno::ENETDOWN
          # link is disconnected
          sleep 1
        end
      end
    end
245756
def read_line(self, time_limit=None):
        
        if self.proc is not None:
            return self.proc.stdout.readline().decode()
        else:
            return None