code: def _read_until(cls, sock, desired_size):
      
      buf = b''
      while len(buf) < desired_size:
        recv_bytes = sock.recv(desired_size - len(buf))
        if not recv_bytes:
          raise cls.TruncatedRead('Expected {} bytes before socket shutdown, instead received {}'
                                  .format(desired_size, len(buf)))
        buf += recv_bytes
      return buf
docs: Read a certain amount of content from a socket before returning.