예제 #1
0
    def Send(self, msg):
        """Send a message.

    This just sends a message and doesn't wait for the response.

    """
        if constants.LUXI_EOM in msg:
            raise errors.ProtocolError("Message terminator found in payload")

        self._CheckSocket()
        self._wstream.write(msg + constants.LUXI_EOM)
        self._wstream.flush()
예제 #2
0
    def Send(self, msg):
        """Send a message.

    This just sends a message and doesn't wait for the response.

    """
        if constants.LUXI_EOM in msg:
            raise errors.ProtocolError("Message terminator found in payload")

        self._CheckSocket()
        try:
            # TODO: sendall is not guaranteed to send everything
            self.socket.sendall(msg + constants.LUXI_EOM)
        except socket.timeout as err:
            raise errors.TimeoutError("Sending timeout: %s" % str(err))
예제 #3
0
파일: transport.py 프로젝트: vali-um/ganeti
  def _CheckSocket(self):
    """Make sure we are connected.

    """
    if self._rstream is None or self._wstream is None:
      raise errors.ProtocolError("Connection is closed")