def _ReadExactlyFailAfterFirst(self, sock, n):
    ret = ""
    left = n
    while left:
      try:
        ret += sock.recv(left)
        if not ret:
          return ""
        left = n - len(ret)
      except socket.timeout:
        if left < n:
          # We have already read some data, so we just give up.
          return ""
      except socket.error:
        return ""
    return ret
Read from socket but return nothing if we get an exception.
dataset/ETHPy150Open google/grr/grr/server/data_server/data_server.py/DataServerHandler._ReadExactlyFailAfterFirst