banyan_base.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:python_banyan 作者: MrYsLab 项目源码 文件源码
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])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号