core.py 文件源码

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

项目:agentzero 作者: gabrielfalcao 项目源码 文件源码
def send_safe(self, name, data, *args, **kw):
        """serializes the data with the configured ``serialization_backend``,
        waits for the socket to become available, then sends it over
        through the provided socket name.

        returns ``True`` if the message was sent, or ``False`` if the
        socket never became available.

        .. note::
          you can safely use this function without waiting for a
          socket to become ready, as it already does it for you.

        raises SocketNotFound when the socket name is wrong.

        :param name: the name of the socket where data should be sent through
        :param data: the data to be serialized then sent
        :param ``*args``: args to be passed to wait_until_ready
        :param ``**kw``: kwargs to be passed to wait_until_ready

        """
        socket = self.wait_until_ready(name, self.zmq.POLLOUT, *args, **kw)

        if not socket:
            return False

        payload = self.serialization_backend.pack(data)
        socket.send(payload)

        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号