def getlines_mainsock(self) -> Generator[str, None, None]: """Yield a set of lines from the socket.""" buf = socket_receive(self.mainsock) done = False while not done: if "\n" in buf: (line, buf) = buf.split("\n", 1) yield line else: more = socket_receive(self.mainsock) if not more: done = True else: buf += more if buf: yield buf
def getlines_immsock(self) -> Generator[str, None, None]: """Yield a set of lines from the socket.""" # http://stackoverflow.com/questions/822001/python-sockets-buffering buf = socket_receive(self.immsock) done = False while not done: if "\n" in buf: (line, buf) = buf.split("\n", 1) yield line else: more = socket_receive(self.immsock) if not more: done = True else: buf += more if buf: yield buf