Commit 358f6a73 authored by Federico Vaga's avatar Federico Vaga

lib:py: bugfix check return value async_recv

Without this patch the code was returning an empty message in case
MockTurtle had nothing to deliver. This is wrong, an empty message
could be a valid message, but in this case we want to tell the user
that the buffer was empty. We do this by returning None.
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent a2a67870
......@@ -552,16 +552,16 @@ class TrtlHmq(object):
:param timeout: time to wait before returning
:type timeout: int
:return: an asynchronous message
:return: an asynchronous message or None
:rtype: TrtlMessage
:raises OSError: from C library errors
"""
set_errno(0)
msg = TrtlMessage()
self.libtrtl.trtl_msg_async_recv(self.trtl_dev.tkn,
self.idx_cpu, self.idx_hmq,
pointer(msg), 1)
return msg
ret = self.libtrtl.trtl_msg_async_recv(self.trtl_dev.tkn,
self.idx_cpu, self.idx_hmq,
pointer(msg), 1)
return None if ret == 0 else msg
def sync_msg(self, msg_s, timeout=1000):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment