ZMQ handle¶
- class uzmq.sock.ZMQ(loop, socket)¶
Bases: object
Parameters: - loop – loop object where this handle runs (accessible through Poll.loop).
- socket (int) – zmq socket
The ZMQ handles provides asynchronous ZMQ sockets functionnality both for bound and connected sockets.
- close()¶
Close the ZMQ handle. After a handle has been closed no other operations can be performed on it.
- flush()¶
Flush pending messages.
This method safely handles all pending incoming and/or outgoing messages, bypassing the inner loop, passing them to the registered callbacks.
- start_read(callback, copy=True, track=False)¶
Parameters: - callback – callable callback must take exactly one argument, which will be a /iist, as returned by socket.recv_multipart() if callback is None, recv callbacks are disabled.
- copy – bool copy is passed directly to recv, so if copy is False, callback will receive Message objects. If copy is True, then callback will receive bytes/str objects.
- track – bool Should the message be tracked for notification that ZMQ has finished with it? (ignored if copy=True)
Callback signature: callback(zmq_handle, msg, error).
Start reading for incoming messages from the remote endpoint.
- stop()¶
Stop the ZMQ handle
- stop_read()¶
Stop reading data from the remote endpoint.
- write(msg, flags=0, copy=True, track=False, callback=None)¶
Parameters: - msg – object, str, Frame The content of the message
- flags – int Any supported flag
- copy – bool Should the message be tracked for notification that ZMQ has finished with it? (ignored if copy=True)
- track – bool Should the message be tracked for notification that ZMQ has finished with it? (ignored if copy=True)
Callback signature: callback(zmq_handle, msg, status).
Send a message. See zmq.socket.send for details.
- write_multipart(msg, flags=0, copy=True, track=False, callback=None)¶
Parameters: - msg – object, str, Frame, the content of the message
- flags – int Any supported flag
- copy – bool Should the message be tracked for notification that ZMQ has finished with it? (ignored if copy=True)
- track – bool Should the message be tracked for notification that ZMQ has finished with it? (ignored if copy=True)
Callback signature: callback(zmq_handle, msg, status).
Send a multipart message. See zmq.socket.send_multipart for details.