code: 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
docs: maxsize is ignored, timeout in seconds is the max time that is way for a complete line