'Reads one line from the stream.'

def readline(self, size=None):

    if (self._pos >= self.limit):
        return self.on_exhausted()
    if (size is None):
        size = (self.limit - self._pos)
    else:
        size = min(size, (self.limit - self._pos))
    try:
        line = self._readline(size)
    except (ValueError, IOError):
        return self.on_disconnect()
    if (size and (not line)):
        return self.on_disconnect()
    self._pos += len(line)
    return line
