Ë
    ˜V.j#  ã                   óŒ   — d Z ddlZddlZddlZddlmZmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZmZmZ d
Z G d„ d«      Zy)zEvent dispatcher sends events.é    N)ÚdefaultdictÚdeque)ÚProducer)Úapp_or_default)Úanon_nodename)Ú	utcoffseté   )ÚEventÚget_exchangeÚ
group_from)ÚEventDispatcherc                   ó¨   — e Zd ZdZdhZdZdZdZ	 	 	 	 dd„Zd„ Z	d„ Z
d„ Zd„ Zd	efd
„Zd	defd„Zd	ed	defd„Zdd„Zd„ Zd„ Zd„ Zd„ Z eee«      Zy)r   a0  Dispatches event messages.

    Arguments:
        connection (kombu.Connection): Connection to the broker.

        hostname (str): Hostname to identify ourselves as,
            by default uses the hostname returned by
            :func:`~celery.utils.anon_nodename`.

        groups (Sequence[str]): List of groups to send events for.
            :meth:`send` will ignore send requests to groups not in this list.
            If this is :const:`None`, all events will be sent.
            Example groups include ``"task"`` and ``"worker"``.

        enabled (bool): Set to :const:`False` to not actually publish any
            events, making :meth:`send` a no-op.

        channel (kombu.Channel): Can be used instead of `connection` to specify
            an exact channel to use when sending events.

        buffer_while_offline (bool): If enabled events will be buffered
            while the connection is down. :meth:`flush` must be called
            as soon as the connection is re-established.

    Note:
        You need to :meth:`close` this after use.
    ÚsqlNc                 ó~  — t        |xs | j                  «      | _        || _        || _        |xs
 t	        «       | _        || _        |
xs
 t        «       | _        || _	        || _
        t        t        «      | _        t        j                  «       | _        d | _        t%        «       | _        |xs  | j                  j(                  j*                  | _        t/        «       | _        t/        «       | _        t/        |xs g «      | _        t6        j8                   t6        j:                   g| _        | j                  j>                  | _        |	| _         |s|r|j                  jB                  | _        || _"        | j                  xs | j                  jG                  «       }tI        || j                  j(                  jJ                  ¬«      | _&        |jN                  jP                  | jR                  v rd| _"        | jD                  r| jU                  «        d| j
                  i| _+        tY        jZ                  «       | _.        y )N)ÚnameFÚhostname)/r   ÚappÚ
connectionÚchannelr   r   Úbuffer_while_offlineÚ	frozensetÚbuffer_groupÚbuffer_limitÚon_send_bufferedr   ÚlistÚ_group_bufferÚ	threadingÚLockÚmutexÚproducerr   Ú_outbound_bufferÚconfÚevent_serializerÚ
serializerÚsetÚ
on_enabledÚon_disabledÚgroupsÚtimeÚtimezoneÚaltzoneÚtzoffsetÚclockÚdelivery_modeÚclientÚenabledÚconnection_for_writer   Úevent_exchangeÚexchangeÚ	transportÚdriver_typeÚDISABLED_TRANSPORTSÚenableÚheadersÚosÚgetpidÚpid)Úselfr   r   r0   r   r   r   r$   r(   r.   r   r   r   Úconninfos                 úZC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\celery/events/dispatcher.pyÚ__init__zEventDispatcher.__init__:   s›  € ô " #¢/¨¯©Ó2ˆŒØ$ˆŒØˆŒØ Ò3¤M£OˆŒØ$8ˆÔ!Ø(Ò7¬I«KˆÔØ(ˆÔØ 0ˆÔÜ(¬Ó.ˆÔÜ—^‘^Ó%ˆŒ
ØˆŒÜ %£ˆÔØ$ÒF¨¯©¯©×(FÑ(FˆŒÜ›%ˆŒÜ›5ˆÔÜ˜&š, BÓ'ˆŒÜŸ-™-˜¬$¯,©,¨Ð7ˆŒØ—X‘X—^‘^ˆŒ
Ø*ˆÔÙ™gØ%×0Ñ0×7Ñ7ˆDŒOØˆŒØ—?‘?ÒE d§h¡h×&CÑ&CÓ&EˆÜ$ XØ*.¯(©(¯-©-×*FÑ*FôHˆŒà×Ñ×)Ñ)¨T×-EÑ-EÑEØ ˆDŒLØ�<Š<Ø�K‰KŒMØ" D§M¡MÐ2ˆŒÜ—9‘9“;ˆ�ó    c                 ó   — | S ©N© ©r<   s    r>   Ú	__enter__zEventDispatcher.__enter__^   s   € Øˆr@   c                 ó$   — | j                  «        y rB   )Úclose)r<   Úexc_infos     r>   Ú__exit__zEventDispatcher.__exit__a   s   € Ø�
‰
�r@   c                 óÂ   — t        | j                  xs | j                  | j                  | j                  d¬«      | _        d| _        | j                  D ]	  } |«        Œ y )NF)r3   r$   Úauto_declareT)r   r   r   r3   r$   r    r0   r&   ©r<   Úcallbacks     r>   r7   zEventDispatcher.enabled   sJ   € Ü  §¡Ò!@°·±Ø*.¯-©-Ø,0¯O©OØ.3ô5ˆŒð ˆŒØŸœˆHÙ�Jñ (r@   c                 ó|   — | j                   r0d| _         | j                  «        | j                  D ]	  } |«        Œ y y )NF)r0   rG   r'   rL   s     r>   ÚdisablezEventDispatcher.disablem   s3   € Ø�<Š<Ø ˆDŒLØ�J‰JŒLØ ×,Ô,�Ù•
ñ -ð r@   Fc           	      ó"  — |rdn| j                   j                  «       } ||f| j                  t        «       | j                  |dœ|¤Ž}| j
                  5   | j                  ||fd|j                  dd«      i|¤Žcddd«       S # 1 sw Y   yxY w)au  Publish event using custom :class:`~kombu.Producer`.

        Arguments:
            type (str): Event type name, with group separated by dash (`-`).
                fields: Dictionary of event fields, must be json serializable.
            producer (kombu.Producer): Producer instance to use:
                only the ``publish`` method will be called.
            retry (bool): Retry in the event of connection failure.
            retry_policy (Mapping): Map of custom retry policy options.
                See :meth:`~kombu.Connection.ensure`.
            blind (bool): Don't set logical clock value (also don't forward
                the internal logical clock).
            Event (Callable): Event type used to create event.
                Defaults to :func:`Event`.
            utcoffset (Callable): Function returning the current
                utc offset in hours.
        N©r   r   r;   r-   Úrouting_keyÚ-Ú.)r-   Úforwardr   r   r;   r   Ú_publishÚreplace)	r<   ÚtypeÚfieldsr    Úblindr
   Úkwargsr-   Úevents	            r>   ÚpublishzEventDispatcher.publisht   s‡   € ñ& ‘ 4§:¡:×#5Ñ#5Ó#7ˆÙ�dð ; T§]¡]¼i»kØŸ(™(¨%ñ;Ø39ñ;ˆà�Z‹ZØ �4—=‘= ¨ñ OØ-1¯\©\¸#¸sÓ-CðOØGMñO÷ �ZŠZús   Á&BÂBc                 ó&  — | j                   }	 |j                  |||j                  |||g| j                  | j                  | j
                  ¬«	       y # t        $ r5}| j                  s‚ | j                  j                  |||f«       Y d }~y d }~ww xY w)N)rR   r3   ÚretryÚretry_policyÚdeclarer$   r8   r.   )
r3   r]   r   r$   r8   r.   Ú	Exceptionr   r!   Úappend)	r<   r\   r    rR   r_   r`   r   r3   Úexcs	            r>   rV   zEventDispatcher._publishŽ   s‘   € à—=‘=ˆð	DØ×ÑØØ'Ø!Ÿ™ØØ)Ø!˜
ØŸ?™?ØŸ™Ø"×0Ñ0ð õ 
øô ò 	DØ×,Ò,ØØ×!Ñ!×(Ñ(¨%°¸cÐ)B×CÑCûð	Dús   ŽAA Á	BÁ+BÂBc           	      ó  — | j                   rö| j                  t        |«      }	}|r|	|vry|	| j                  v r¨| j                  j                  «       }
 ||f| j                   |«       | j                  |
dœ|¤Ž}| j                  |	   }|j                  |«       t        |«      | j                  k\  r| j                  «        y| j                  r| j                  «        yy| j                  ||| j                  ||||¬«      S y)aÆ  Send event.

        Arguments:
            type (str): Event type name, with group separated by dash (`-`).
            retry (bool): Retry in the event of connection failure.
            retry_policy (Mapping): Map of custom retry policy options.
                See :meth:`~kombu.Connection.ensure`.
            blind (bool): Don't set logical clock value (also don't forward
                the internal logical clock).
            Event (Callable): Event type used to create event,
                defaults to :func:`Event`.
            utcoffset (Callable): unction returning the current utc offset
                in hours.
            **fields (Any): Event fields -- must be json serializable.
        NrQ   )rZ   r
   r_   r`   )r0   r(   r   r   r-   rU   r   r;   r   rc   Úlenr   Úflushr   r]   r    )r<   rX   rZ   r   r_   r`   r
   rY   r(   Úgroupr-   r\   Úbufs                r>   ÚsendzEventDispatcher.send¢   sþ   € ð" �<Š<Ø ŸK™K¬°DÓ)9�EˆFÙ˜% vÑ-ØØ˜×)Ñ)Ñ)ØŸ
™
×*Ñ*Ó,�Ù˜dð C¨T¯]©]Ù(1«Ø"&§(¡(°%ñCà;AñC�ð ×(Ñ(¨Ñ/�Ø—
‘
˜5Ô!Ü�s“8˜t×0Ñ0Ò0Ø—J‘J•LØ×*Ò*Ø×)Ñ)Õ+ð +ð —|‘| D¨&°$·-±-ÀuØ*/°uØ1=ð $ó ?ð ?ð! r@   c                 ó  — |rnt        | j                  «      }	 | j                  5  |D ]#  \  }}}| j                  || j                  |«       Œ% 	 ddd«       | j                  j                  «        |r^| j                  5  | j                  j                  «       D ]*  \  }}| j                  || j                  d|z  «       g |dd Œ, 	 ddd«       yy# 1 sw Y   Œ„xY w# | j                  j                  «        w xY w# 1 sw Y   yxY w)zFlush the outbound buffer.Nz%s.multi)r   r!   r   rV   r    Úclearr   Úitems)	r<   Úerrorsr(   ri   r\   rR   Ú_rh   Úeventss	            r>   rg   zEventDispatcher.flushÇ   sØ   € áÜ�t×,Ñ,Ó-ˆCð.Ø—Z“ZÛ14Ñ-˜˜{¨AØŸ™ e¨T¯]©]¸KÕHñ 25÷  ð ×%Ñ%×+Ñ+Ô-ÙØ—“Ø%)×%7Ñ%7×%=Ñ%=Ö%?‘M�E˜6Ø—M‘M &¨$¯-©-¸ÀeÑ9KÔLØ "�F™1‘Iñ &@÷ �ð ÷  �Zûð ×%Ñ%×+Ñ+Õ-úç�ús/   ™C ¥)CÁC Á?AC=ÃCÃC ÃC:Ã=Dc                 óN   — | j                   j                  |j                   «       y)z-Copy the outbound buffer of another instance.N)r!   Úextend)r<   Úothers     r>   Úextend_bufferzEventDispatcher.extend_buffer×   s   € à×Ñ×$Ñ$ U×%;Ñ%;Õ<r@   c                 ó~   — | j                   j                  «       xr | j                   j                  «        d| _        y)zClose the event dispatcher.N)r   ÚlockedÚreleaser    rD   s    r>   rG   zEventDispatcher.closeÛ   s,   € à�
‰
×ÑÓÒ4 §
¡
× 2Ñ 2Ó 4øØˆ�r@   c                 ó   — | j                   S rB   ©r    rD   s    r>   Ú_get_publisherzEventDispatcher._get_publisherà   s   € Ø�}‰}Ðr@   c                 ó   — || _         y rB   ry   )r<   r    s     r>   Ú_set_publisherzEventDispatcher._set_publisherã   s	   € Ø ˆ�r@   )NNTNTNNNr	   Né   N)TT)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r6   r   r&   r'   r?   rE   rI   r7   rO   r
   r]   r   rV   rj   rg   rt   rG   rz   r|   ÚpropertyÚ	publisherrC   r@   r>   r   r      s¡   „ ñð8 !˜'Ðà
€Cð €Jð €Kà?CØ>BØ=>ØFJó"òHòòòð  5óOð4 <AØ"¨ióDð(  %°	ÀØ eó#?óJ#ò =òò
ò!á˜¨Ó8�Ir@   r   )r�   r9   r   r)   Úcollectionsr   r   Úkombur   Ú
celery.appr   Úcelery.utils.nodenamesr   Úcelery.utils.timer   r\   r
   r   r   Ú__all__r   rC   r@   r>   Ú<module>rŠ      s7   ðÙ $ã 	Û Û ß *å å %Ý 0Ý 'ç 2Ñ 2à
€÷R9ò R9r@   