def sendMessage(self, mtype, objname, data):
"""
Send message is responsable for transmission of cobra messages,
and socket reconnection in the event that the send fails for network
reasons.
"""
# NOTE: for errors while using msgpack, we must send only the str
if mtype == COBRA_ERROR and self.sflags & (SFLAG_MSGPACK | SFLAG_JSON):
data = str(data)
try:
buf = self.dumps(data)
except Exception as e:
raise CobraPickleException("The arguments/attributes must be serializable: %s" % e)
objname = toUtf8(objname)
self.sendExact(struct.pack("<III", mtype, len(objname), len(buf)) + objname + buf)
评论列表
文章目录