ZMQ handle

class uzmq.sock.ZMQ(loop, socket)[source]

Bases: object

Parameters:
  • loop – loop object where this handle runs (accessible through Poll.loop).
  • socket (int) – zmq socket

The ZMQ handles provides qsynchronous ZMQ sockets functionnality both for bound and connected sockets.

close()[source]

Close the ZMQ handle. After a handle has been closed no other operations can be performed on it.

flush()[source]

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)[source]
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()[source]

Stop the ZMQ handle

stop_read()[source]

Stop reading data from the remote endpoint.

write(msg, flags=0, copy=True, track=False, callback=None)[source]
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)[source]
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.

Previous topic

ZMQPoll handle

Next topic

CHANGES

This Page