Ë
    Ÿõf  ã                  ój   — d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	  G d„ d«      Z
 e
«       Zdd	gZy)
z(Tracker for zero-copy messages with 0MQ.é    )ÚannotationsN)ÚEvent)ÚFrame)ÚNotDonec                  óH   — e Zd ZU dZded<   ded<   d
d„Zed„ «       Zddd„Zy	)ÚMessageTrackera­  A class for tracking if 0MQ is done using one or more messages.

    When you send a 0MQ message, it is not sent immediately. The 0MQ IO thread
    sends the message at some later time. Often you want to know when 0MQ has
    actually sent the message though. This is complicated by the fact that
    a single 0MQ message can be sent multiple times using different sockets.
    This class allows you to track all of the 0MQ usages of a message.

    Parameters
    ----------
    towatch : Event, MessageTracker, zmq.Frame
        This objects to track. This class can track the low-level
        Events used by the Message class, other MessageTrackers or
        actual Messages.
    z
set[Event]Úeventszset[MessageTracker]Úpeersc                óÄ  — t        «       | _        t        «       | _        |D ]½  }t        |t        «      r| j                  j                  |«       Œ/t        |t        «      r| j                  j                  |«       Œ[t        |t        «      r=|j                  st        d«      ‚| j                  j                  |j                  «       Œ¨t        dt        |«      › «      ‚ y)a\  Create a message tracker to track a set of messages.

        Parameters
        ----------
        *towatch : tuple of Event, MessageTracker, Message instances.
            This list of objects to track. This class can track the low-level
            Events used by the Message class, other MessageTrackers or
            actual Messages.
        zNot a tracked messagez&Require Events or Message Frames, not N)Úsetr	   r
   Ú
isinstancer   Úaddr   r   ÚtrackerÚ
ValueErrorÚ	TypeErrorÚtype)ÚselfÚtowatchÚobjs      úL/var/www/cvtools/html/venv/lib/python3.12/site-packages/zmq/sugar/tracker.pyÚ__init__zMessageTracker.__init__#   s£   € ô “eˆŒÜ“UˆŒ
Øò 
	VˆCÜ˜#œuÔ%Ø—‘—‘ Õ$Ü˜C¤Ô0Ø—
‘
—‘˜sÕ#Ü˜C¤Ô'Ø—{’{Ü$Ð%<Ó=Ð=Ø—
‘
—‘˜sŸ{™{Õ+äÐ"HÌÈcËÈÐ TÓUÐUñ
	Vó    c                óˆ   — | j                   D ]  }|j                  «       rŒ y | j                  D ]  }|j                  rŒ y y)z9Is 0MQ completely done with the message(s) being tracked?FT)r	   Úis_setr
   Údone)r   ÚevtÚpms      r   r   zMessageTracker.done;   sG   € ð —;‘;ò 	ˆCØ—:‘:•<Ùð	ð —*‘*ò 	ˆBØ—7“7Ùð	ð r   c                ó¤  — t        j                   «       }|du s|dk  rd}n|}| j                  D ]S  }|dk  rt        ‚|j                  |¬«       |j	                  «       st        ‚t        j                   «       }|||z
  z  }|}ŒU | j
                  D ]=  }|dk  rt        ‚|j                  |¬«       t        j                   «       }|||z
  z  }|}Œ? y)a¬  Wait for 0MQ to be done with the message or until `timeout`.

        Parameters
        ----------
        timeout : float
            default: -1, which means wait forever.
            Maximum time in (s) to wait before raising NotDone.

        Returns
        -------
        None
            if done before `timeout`

        Raises
        ------
        NotDone
            if `timeout` reached before I am done.
        Fr   i€:	 )ÚtimeoutN)Útimer	   r   Úwaitr   r
   )r   r   ÚticÚ	remainingr   ÚtocÚpeers          r   r!   zMessageTracker.waitF   sÍ   € ô& i‰i‹kˆàeÑ˜w¨š{Ø%‰IàˆIØ—;‘;ò 	ˆCØ˜1Š}ÜØH‰H˜YˆHÔ'Ø—:‘:”<ÜÜ—)‘)“+ˆCØ˜˜s™Ñ"ˆIØ‰Cð	ð —J‘Jò 	ˆDØ˜1Š}ÜØI‰I˜iˆIÔ(Ü—)‘)“+ˆCØ˜˜s™Ñ"ˆIØ‰Cñ	r   N)r   z%tuple[MessageTracker | Event | Frame])éÿÿÿÿ)r   zfloat | int)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   Úpropertyr   r!   © r   r   r   r      s4   … ñð  ÓØÓóVð0 ñó ðõ)r   r   Ú_FINISHED_TRACKER)r*   Ú
__future__r   r    Ú	threadingr   Úzmq.backendr   Ú	zmq.errorr   r   r.   Ú__all__r-   r   r   ú<module>r4      s<   ðÙ .õ
 #ã Ý å Ý ÷`ñ `ñF #Ó$Ð àÐ0Ð
1r   