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
评论列表
文章目录