code: def handle_lines(self):
          
          while "\r\n" in self.buffer:
              line, self.buffer = self.buffer.split("\r\n", 1)
              if valid_packet(line):
                  self.handle_raw_packet(line)
              else:
                  log.warning('dropping invalid data: %s', line)
docs: Assemble incoming data into per-line packets.