Ë
    3ýjP  ã                   ó¬   — d Z ddl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 ddlmZ dd	lmZ dd
lmZ ddlmZ dZdZ edd«      Z G d„ de	«      Zy)zEvent receiver implementation.é    N)Ú
itemgetter)ÚQueue)Úmaybe_channel)ÚConsumerMixin)Úuuid)Úapp_or_default)ÚImproperlyConfigured)Úadjust_timestampé   )Úget_exchange)ÚEventReceiveréÿÿÿÿÚ	utcoffsetÚ	timestampc                   ó–   — e Zd ZdZdZ	 	 	 	 	 dd„Zd„ Zd„ Z	 dd„Zdd„Z	dd	„Z
dd
„Zdej                  eeefd„Zeefd„Zed„ «       Zy)r   a®  Capture events.

    Arguments:
        channel (kombu.Channel): Channel to consume events on. A
            :class:`kombu.Connection` is also accepted, in which case its
            default channel is used.
        handlers (Mapping[Callable]): Event handlers.
            This is  a map of event type names and their handlers.
            The special handler `"*"` captures all events that don't have a
            handler.
    Nc           
      ór  — t        |xs | j                  «      | _        t        |«      | _        |€i n|| _        || _        |xs
 t        «       | _        |xs  | j                  j                  j                  | _
        t        | j                  xs | j                  j                  «       | j                  j                  j                  ¬«      | _        |€ | j                  j                  j                   }|	€ | j                  j                  j"                  }	|
€ | j                  j                  j$                  }
|€ | j                  j                  j&                  }|
r|rt)        d«      ‚t+        dj-                  | j                  | j                  g«      | j                  | j
                  | ||
||	¬«      | _        | j                  j0                  | _        | j0                  j2                  | _        | j0                  j6                  | _        |€"| j                  j                  j:                  dh}|| _        y )N)ÚnamezDQueue cannot be both exclusive and durable, choose one or the other.ú.)ÚexchangeÚrouting_keyÚauto_deleteÚdurableÚ	exclusiveÚmessage_ttlÚexpiresÚjson)r   Úappr   ÚchannelÚhandlersr   r   Únode_idÚconfÚevent_queue_prefixÚqueue_prefixr   Ú
connectionÚconnection_for_writeÚevent_exchanger   Úevent_queue_ttlÚevent_queue_expiresÚevent_queue_exclusiveÚevent_queue_durabler	   r   ÚjoinÚqueueÚclockÚadjustÚadjust_clockÚforwardÚforward_clockÚevent_serializerÚaccept)Úselfr   r   r   r    r   r#   r3   Ú	queue_ttlÚqueue_expiresÚqueue_exclusiveÚqueue_durables               úP/root/telegram-saas/.venv/lib/python3.12/site-packages/celery/events/receiver.pyÚ__init__zEventReceiver.__init__&   sº  € ô
 " #¢/¨¯©Ó2ˆŒÜ$ WÓ-ˆŒØ&Ð.™°HˆŒØ&ˆÔØÒ(¤$£&ˆŒØ(ÒL¨D¯H©H¯M©M×,LÑ,LˆÔÜ$Ø�O‰OÒ>˜tŸx™x×<Ñ<Ó>Ø—‘—‘×-Ñ-ô/ˆŒð ÐØŸ™Ÿ™×5Ñ5ˆIØÐ Ø ŸH™HŸM™M×=Ñ=ˆMØÐ"Ø"Ÿh™hŸm™m×AÑAˆOØÐ Ø ŸH™HŸM™M×=Ñ=ˆMÙ™}Ü&ð+óð ô Ø�H‰H�d×'Ñ'¨¯©Ð6Ó7Ø—]‘]Ø×(Ñ(Ø)Ð)Ø!Ø%Ø!Ø!ô	
ˆŒ
ð —X‘X—^‘^ˆŒ
Ø ŸJ™J×-Ñ-ˆÔØ!ŸZ™Z×/Ñ/ˆÔØˆ>Ø—h‘h—m‘m×4Ñ4°fÐ=ˆFØˆ�ó    c                 ó�   — | j                   j                  |«      xs | j                   j                  d«      }|xr
  ||«       y y)z3Process event by dispatching to configured handler.Ú*N)r   Úget)r4   ÚtypeÚeventÚhandlers       r9   ÚprocesszEventReceiver.processR   s9   € à—-‘-×#Ñ# DÓ)ÒC¨T¯]©]×->Ñ->¸sÓ-CˆØÒ"‘G˜E•NÑ"r;   c                 ó\   —  || j                   g| j                  gd| j                  ¬«      gS )NT)ÚqueuesÚ	callbacksÚno_ackr3   )r,   Ú_receiver3   )r4   ÚConsumerr   s      r9   Úget_consumerszEventReceiver.get_consumersW   s.   € Ù §¡ Ø$(§M¡M ?¸4Ø $§¡ô-ð .ð 	.r;   Tc                 ó.   — |r| j                  |¬«       y y )N)r   )Úwakeup_workers)r4   r$   r   Ú	consumersÚwakeupÚkwargss         r9   Úon_consume_readyzEventReceiver.on_consume_ready\   s   € áØ×Ñ¨ÐÕ0ð r;   c                 ó*   — | j                  |||¬«      S )N©ÚlimitÚtimeoutrM   ©Úconsume)r4   rR   rS   rM   s       r9   ÚitercapturezEventReceiver.itercapturea   s   € Ø�|‰| %°Àˆ|ÓHÐHr;   c                 ó6   — | j                  |||¬«      D ]  }Œ y)zúOpen up a consumer capturing events.

        This has to run in the main process, and it will never stop
        unless :attr:`EventDispatcher.should_stop` is set to True, or
        forced via :exc:`KeyboardInterrupt` or :exc:`SystemExit`.
        rQ   NrT   )r4   rR   rS   rM   Ú_s        r9   ÚcapturezEventReceiver.captured   s%   € ð —‘ E°7À6�ÓJò 	ˆAØñ	r;   c                 óh   — | j                   j                  j                  d| j                  |¬«       y )NÚ	heartbeat)r$   r   )r   ÚcontrolÚ	broadcastr$   )r4   r   s     r9   rK   zEventReceiver.wakeup_workersn   s+   € Ø�‰×Ñ×"Ñ" ;Ø.2¯o©oØ+2ð 	#õ 	4r;   c                 ó^  — |d   }|dk(  r4| j                   j                  xs d|z   x}|d<   | j                  |«       n	 |d   }	| j                  |	«       |r	  ||«      \  }
} |||
«      |d<    |«       |d<   ||fS # t        $ r | j	                  «       |d<   Y ŒFw xY w# t        $ r Y Œ;w xY w)Nr?   z	task-sentr   r-   r   Úlocal_received)r-   Úvaluer/   ÚKeyErrorr1   )r4   ÚbodyÚlocalizeÚnowÚtzfieldsr
   ÚCLIENT_CLOCK_SKEWr?   Ú_cr-   Úoffsetr   s               r9   Úevent_from_messagez EventReceiver.event_from_messages   sÛ   € ð �F‰|ˆØ�;Òà"&§*¡*×"2Ñ"2Ò"7°aÐ;LÑ!LÐLˆB��g‘Ø×Ñ˜bÕ!ð)Ø˜W™�ð ×!Ñ! %Ô(áðHÙ$,¨T£NÑ!�˜	ñ %5°YÀÓ$G��[Ñ!Ù!$£ˆÐÑØ�TˆzÐøô ò 5Ø $× 2Ñ 2Ó 4��W“ð5ûô ò Ùðús$   Á A> ÁB  Á>BÂBÂ 	B,Â+B,c                 óÀ   —  |||«      r2| j                   | j                  }}|D �cg c]  } | ||«      Ž ‘Œ c} y  | j                   | j                  |«      Ž  y c c}w ©N)rB   ri   )r4   rb   ÚmessageÚlistÚ
isinstancerB   Úfrom_messager@   s           r9   rG   zEventReceiver._receiveŽ   sU   € Ù�d˜DÔ!Ø$(§L¡L°$×2IÑ2I�\ˆGØ8<Ö=¨u‰W‘l 5Ó)Ò*Ô=àˆD�L‰L˜$×1Ñ1°$Ó7Ò8ùò >s   ¦Ac                 ó^   — | j                   r | j                   j                  j                  S d S rk   )r   r$   Úclient)r4   s    r9   r$   zEventReceiver.connection•   s#   € à15·²ˆt�|‰|×&Ñ&×-Ñ-ÐGÀ4ÐGr;   )
Nú#NNNNNNNN)T)NNTrk   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r:   rB   rI   rO   rV   rY   rK   ÚtimeÚ	_TZGETTERr
   rf   ri   rm   rn   rG   Úpropertyr$   © r;   r9   r   r      s‚   „ ñ
ð €Cà;>Ø6:Ø<@Ø!%Ø#ó	*òX#ò
.ð !%ó1ó
Ióó4ð
 15Ø#Ÿy™y°9Ø,<Ø->óð6 ,0¸Jó 9ð ñHó ñHr;   r   )rv   rw   Úoperatorr   Úkombur   Úkombu.connectionr   Úkombu.mixinsr   Úceleryr   Ú
celery.appr   Úcelery.exceptionsr	   Úcelery.utils.timer
   r@   r   Ú__all__rf   rx   r   rz   r;   r9   ú<module>r„      sM   ðÙ $Û Ý å Ý *Ý &å Ý %Ý 2Ý .å à
€àÐ á�{ KÓ0€	ô@H�Mõ @Hr;   