utils.monitor#

Module: zmq.utils.monitor#

Module holding utility and convenience functions for zmq event monitoring.

Functions#

zmq.utils.monitor.parse_monitor_message(msg: list[bytes]) dict#

decode zmq_monitor event messages.

Parameters:

msg (list(bytes)) –

zmq multipart message that has arrived on a monitor PAIR socket.

First frame is:

16 bit event id
32 bit event value
no padding

Second frame is the endpoint as a bytestring

Returns:

event – event description as dict with the keys event, value, and endpoint.

Return type:

dict

zmq.utils.monitor.recv_monitor_message(socket: Socket, flags: int = 0) Awaitable[dict]#
zmq.utils.monitor.recv_monitor_message(socket: Socket[bytes], flags: int = 0) dict

Receive and decode the given raw message from the monitoring socket and return a dict.

Requires libzmq ≥ 4.0

The returned dict will have the following entries:
eventint

the event id as described in libzmq.zmq_socket_monitor

valueint

the event value associated with the event, see libzmq.zmq_socket_monitor

endpointstr

the affected endpoint

Changed in version 23.1: Support for async sockets added. When called with a async socket, returns an awaitable for the monitor message.

Parameters:
  • socket (zmq.Socket) – The PAIR socket (created by other.get_monitor_socket()) on which to recv the message

  • flags (int) – standard zmq recv flags

Returns:

event – event description as dict with the keys event, value, and endpoint.

Return type:

dict