
    ^h                        S r SSKJr  SSKrSSKJrJrJr  SSKrSSK	rSSK
Jr   " S S\5      rSS jr    SS	 jr\ S     SS
 jj5       r\ S     SS jj5       r S     SS jjrSS/rg)zJModule holding utility and convenience functions for zmq event monitoring.    )annotationsN)	Awaitable	TypedDictoverload)_check_versionc                  4    \ rS rSr% S\S'   S\S'   S\S'   Srg)	_MonitorMessage   inteventvaluebytesendpoint N)__name__
__module____qualname____firstlineno____annotations____static_attributes__r       K/home/james-whalen/.local/lib/python3.13/site-packages/zmq/utils/monitor.pyr	   r	      s    JJOr   r	   c                    [        U 5      S:w  d  [        U S   5      S:w  a  [        SU  35      e[        R                  " SU S   5      u  p[        R
                  " U5      [        R
                  " U5      U S   S.nU$ )a  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 : dict
    event description as dict with the keys `event`, `value`, and `endpoint`.
   r      zInvalid event message format: z=hi   )r   r   r   )lenRuntimeErrorstructunpackzmqEvent)msgevent_idr   r   s       r   parse_monitor_messager%      st    * 3x1}CFq(;C5ABBmmE3q62OH8$5!FE
 Lr   c                8   #    U I Sh  vN n[        U5      $  N7f)zqLike parse_monitor_msg, but awaitable

Given awaitable message, return awaitable for the parsed monitor message.
N)r%   )awaitable_msgr#   s     r   _parse_monitor_msg_asyncr(   6   s      
C %% s   c                    g Nr   socketflagss     r   recv_monitor_messager.   C   s     "%r   c                    g r*   r   r+   s     r   r.   r.   J   s     r   c                    [        SS5        U R                  U5      n[        U[        5      (       a  [	        U5      $ [        U5      $ )u%  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:
  event : int
    the event id as described in `libzmq.zmq_socket_monitor`
  value : int
    the event value associated with the event, see `libzmq.zmq_socket_monitor`
  endpoint : str
    the affected endpoint

.. versionchanged:: 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 : dict
    event description as dict with the keys `event`, `value`, and `endpoint`.
)   r   zlibzmq event API)r   recv_multipart
isinstancer   r(   r%   )r,   r-   r#   s      r   r.   r.   Q   sG    D 6-.



&C #y!!',, !%%r   r%   r.   )r#   zlist[bytes]returnr	   )r'   zAwaitable[list[bytes]]r4   r	   )r   )r,   zzmq.asyncio.Socketr-   r   r4   zAwaitable[_MonitorMessage])r,   zzmq.Socket[bytes]r-   r   r4   r	   )r,   z
zmq.Socketr-   r   r4   z,_MonitorMessage | Awaitable[_MonitorMessage])__doc__
__future__r   r   typingr   r   r   r!   zmq.asyncio	zmq.errorr   r	   r%   r(   r.   __all__r   r   r   <module>r;      s    P
 #  1 1 
  $i @
&)
&
& 
 %%%  % 
% 
   
 ,&,&,& 2,&^ #$:
;r   