Skip to content
Snippets Groups Projects
Commit 5b556887 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Merge branch '26_fix_decoding_error' into 'master'

Do not systematically decode incoming zmq parts

Closes #26

See merge request !59
parents 5aa0b82f 0a1c91f5
No related branches found
No related tags found
1 merge request!59Do not systematically decode incoming zmq parts
Pipeline #33586 passed
......@@ -143,9 +143,9 @@ class MessageHandler(threading.Thread):
more = True
parts = []
while more:
parts.append(self.socket.recv().decode("utf-8"))
parts.append(self.socket.recv())
more = self.socket.getsockopt(zmq.RCVMORE)
command = parts[0]
command = parts[0].decode("utf-8")
if command in self.callbacks:
try: # to handle command
......@@ -176,7 +176,8 @@ class MessageHandler(threading.Thread):
import traceback
def parser(s):
return s if len(s) < 20 else s[:20] + "..."
parsed = s if len(s) < 20 else s[:20] + b"..."
return parsed.decode("utf-8")
parsed_parts = " ".join([parser(k) for k in parts])
message = (
......@@ -229,6 +230,9 @@ class MessageHandler(threading.Thread):
def error(self, t, msg):
"""Syntax: err type message"""
t = t.decode("utf-8")
msg = msg.decode("utf-8")
logger.debug("recv: err %s <msg> (size=%d)", t, len(msg))
if t == "usr":
......@@ -242,6 +246,7 @@ class MessageHandler(threading.Thread):
def infos(self, name):
"""Syntax: ifo name"""
name = name.decode("utf-8")
logger.debug("recv: ifo %s", name)
if self.data_sources is None:
......@@ -268,6 +273,9 @@ class MessageHandler(threading.Thread):
def get_data(self, name, index):
"""Syntax: get name index"""
name = name.decode("utf-8")
index = index.decode("utf-8")
logger.debug("recv: get %s %s", name, index)
if self.data_sources is None:
......@@ -393,12 +401,11 @@ class LoopMessageHandler(MessageHandler):
Result to be validated.
"""
result = result.encode("utf-8")
logger.debug("recv: val %s", result)
data = self.request_data_format.type()
data.unpack(result)
logger.debug("recv: val %s", data)
is_valid, answer = self.executor.validate(data)
data = make_data_format(answer, self.answer_data_format)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment