def publish_payload(self, payload, topic=''):
"""
This method will publish a python_banyan payload and its associated topic
:param payload: Protocol message to be published
:param topic: A string value
"""
if not type(topic) is str:
if sys.version_info[0] < 3:
raise AttributeError('Publish topic must be python_banyan string', 'topic')
else:
raise TypeError('Publish topic must be python_banyan string', 'topic')
# create python_banyan message pack payload
if self.numpy:
message = msgpack.packb(payload, default=m.encode)
else:
message = umsgpack.packb(payload)
pub_envelope = topic.encode()
self.publisher.send_multipart([pub_envelope, message])
评论列表
文章目录