Ë
    3ýj”~  ã                  ó  — d 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mZmZ dd
lmZmZmZ ddlmZ ddlmZmZ ddlmZmZ erddlmZ dZdZ  G d„ d«      Z! G d„ d«      Z" G d„ d«      Z# G d„ d«      Z$y)zSending and receiving messages.é    )Úannotations)Úcount)Úlocal)ÚTYPE_CHECKINGé   )Úmaybe_declare)Úcompress)ÚPooledConnectionÚis_connectionÚmaybe_channel)ÚExchangeÚQueueÚmaybe_delivery_mode)ÚContentDisallowed)ÚdumpsÚprepare_accept_content)ÚChannelPromiseÚ
maybe_list)ÚTracebackType)r   r   ÚProducerÚConsumeréè  c                  ó4   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)	Ú_ProducerBatchStatez=State shared by nested batch contexts in one producer thread.c                ó<   — || _         d| _        d | _        d| _        y ©NF)Úmax_sizeÚabortedÚsessionÚ	immediate©Úselfr   s     úI/root/telegram-saas/.venv/lib/python3.12/site-packages/kombu/messaging.pyÚ__init__z_ProducerBatchState.__init__   s   € Ø ˆŒØˆŒØˆŒØˆ�ó    c                ó&  — | j                   ry | j                  €Jt        |dd «      }t        |dd«      }|�|sd| _         y  || j                  ¬«      | _        | j                  S | j                  j                  |urt        d«      ‚| j                  S )NÚcreate_publish_batchÚsupports_batch_publishT)r   z9Producer channel changed while a publish batch was active)r    r   Úgetattrr   ÚchannelÚRuntimeError)r"   r*   Úcreate_batchÚsupports_batchs       r#   Ú_get_sessionz _ProducerBatchState._get_session"   s’   € Ø�>Š>ØØ�<‰<ÐÜ" 7Ð,BÀDÓIˆLÜ$ WÐ.FÈÓMˆNØÐ#©>Ø!%�”ØÙ'°·±Ô?ˆDŒLð
 �|‰|Ðð	 �\‰\×!Ñ!¨Ñ0ÜØKóð ð �|‰|Ðr%   c                ó¢   — | j                   rt        d«      ‚| j                  |«      }|€ |j                  |fi |¤ŽS  |j                  |fi |¤ŽS )Nz'Cannot publish through an aborted batch)r   r+   r.   Úbasic_publishÚpublish)r"   r*   ÚmessageÚkwargsr   s        r#   r1   z_ProducerBatchState.publish2   sX   € Ø�<Š<ÜÐHÓIÐIØ×#Ñ# GÓ,ˆØˆ?Ø(�7×(Ñ(¨Ñ;°FÑ;Ð;Øˆw�‰˜wÑ1¨&Ñ1Ð1r%   c                ó€   — | j                   rt        d«      ‚| j                  �| j                  j                  «        y y )NzCannot flush an aborted batch)r   r+   r   Úflush©r"   s    r#   r5   z_ProducerBatchState.flush:   s4   € Ø�<Š<ÜÐ>Ó?Ð?Ø�<‰<Ð#Ø�L‰L×ÑÕ ð $r%   c                óz   — | j                   ry d| _         | j                  �| j                  j                  «        y y )NT)r   r   Údiscardr6   s    r#   Úabortz_ProducerBatchState.abort@   s2   € Ø�<Š<ØØˆŒØ�<‰<Ð#Ø�L‰L× Ñ Õ"ð $r%   c                óR   — | j                   �| j                   j                  «        y y ©N)r   Úcloser6   s    r#   r<   z_ProducerBatchState.closeG   s!   € Ø�<‰<Ð#Ø�L‰L×ÑÕ ð $r%   N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r$   r.   r1   r5   r9   r<   © r%   r#   r   r      s#   „ ÙGòòò 2ò!ò#ó!r%   r   c                  ó(   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zy)Ú_ProducerBatchz3Context manager returned by :meth:`Producer.batch`.c                óX   — || _         || _        d | _        d| _        d| _        d| _        y r   )Úproducerr   ÚstateÚis_outermostÚenteredÚactive)r"   rE   r   s      r#   r$   z_ProducerBatch.__init__O   s-   € Ø ˆŒØ ˆŒØˆŒ
Ø!ˆÔØˆŒØˆ�r%   c                ó  — | j                   rt        d«      ‚d| _         d| _        t        | j                  j
                  dd «      }|€7t        | j                  «      }|| j                  j
                  _        d| _	        || _
        | S )Nz*Publish batch context cannot be re-enteredTÚcurrent)rH   r+   rI   r)   rE   Ú_batch_localr   r   rK   rG   rF   )r"   rF   s     r#   Ú	__enter__z_ProducerBatch.__enter__W   st   € Ø�<Š<ÜÐKÓLÐLØˆŒØˆŒä˜Ÿ™×2Ñ2°I¸tÓDˆØˆ=Ü'¨¯©Ó6ˆEØ16ˆD�M‰M×&Ñ&Ô.Ø $ˆDÔØˆŒ
Øˆr%   c                óÐ  — | j                   }|€y d }	 | j                  r| j                  j                  `|�	 |j                  «        | j                  r0|€|j                  s	 |j                  «        	 |j                  «        d| _
        |€|�|‚y # t        $ r}|}Y d }~ŒZd }~ww xY w# t        $ r}|}Y d }~ŒGd }~ww xY w# t        $ r}|€|}Y d }~ŒPd }~ww xY w# d| _
        w xY wr   )rF   rG   rE   rL   rK   r9   ÚBaseExceptionr   r5   r<   rI   )r"   Úexc_typeÚ	exc_valueÚ	tracebackrF   Úcleanup_errorÚexcs          r#   Ú__exit__z_ProducerBatch.__exit__e   sî   € Ø—
‘
ˆØˆ=Øàˆð	 Ø× Ò Ø—M‘M×.Ñ.Ð6àÐ#ð(Ø—K‘K”Mð × Ò ØÐ#¨E¯MªMð,ØŸ™œð,Ø—K‘K”Mð
  ˆDŒKàÐ Ð 9ØÐØøô' %ò (Ø$'•Mûð(ûô )ò ,Ø(+�ûð,ûô %ò ,Ø$Ð,Ø(+˜ÿøð,ûð  ˆD�Kús|   “$C ¸B ÁC Á#B* Á4C Â	B'ÂB"ÂC Â"B'Â'C Â*	B?Â3B:Â5C Â:B?Â?C Ã	CÃCÃC ÃCÃC Ã	C%c                óf   — | j                   st        d«      ‚| j                  j                  «        y)z,Flush messages buffered by the active batch.z#Publish batch context is not activeN)rI   r+   rF   r5   r6   s    r#   r5   z_ProducerBatch.flush‡   s%   € à�{Š{ÜÐDÓEÐEØ�
‰
×ÑÕr%   N)r=   r>   r?   r@   r$   rM   rU   r5   rA   r%   r#   rC   rC   L   s   „ Ù=òòò óDr%   rC   c                  ó  — e Zd ZdZdZdZdZdZdZdZ	dZ
	 	 	 dd„Zd„ Zd„ Zd„ Zd	„ Zdd
„Zed„ «       Zefd„Zdeefd„Z	 	 	 	 	 	 dd„Z	 dd„Zd„ Zd„ Z eee«      Zd„ Zd„ Z	 	 	 	 	 	 	 	 dd„Zd„ Z e Z!	 	 dd„Z"ed„ «       Z#y)r   a€  Message Producer.

    Arguments:
    ---------
        channel (kombu.Connection, ChannelT): Connection or channel.
        exchange (kombu.entity.Exchange, str): Optional default exchange.
        routing_key (str): Optional default routing key.
        serializer (str): Default serializer. Default is `"json"`.
        compression (str): Default compression method.
            Default is no compression.
        auto_declare (bool): Automatically declare the default exchange
            at instantiation. Default is :const:`True`.
        on_return (Callable): Callback to call for undeliverable messages,
            when the `mandatory` or `immediate` arguments to
            :meth:`publish` is used. This callback needs the following
            signature: `(exception, exchange, routing_key, message)`.
            Note that the producer needs to drain events to use this feature.
    NÚ Tc                óŽ  — || _         || _        |xs | j                  | _        |xs | j                  | _        |xs | j                  | _        |xs | j
                  | _        d | _        t        «       | _        | j                  €t        d«      | _        |�|| _
        | j                   r| j                  | j                   «       y y )NrX   )Ú_channelÚexchangeÚrouting_keyÚ
serializerÚcompressionÚ	on_returnÚ_channel_promiser   rL   r   Úauto_declareÚrevive)r"   r*   r[   r\   r]   ra   r^   r_   s           r#   r$   zProducer.__init__¹   s©   € ð  ˆŒØ ˆŒØ&Ò:¨$×*:Ñ*:ˆÔØ$Ò7¨¯©ˆŒØ&Ò:¨$×*:Ñ*:ˆÔØ"Ò4 d§n¡nˆŒØ $ˆÔÜ!›GˆÔØ�=‰=Ð Ü$ R›LˆDŒMØÐ#Ø ,ˆDÔà�=Š=Ø�K‰K˜Ÿ™Õ&ð r%   c                ó"   — d| j                   › d�S )Nz<Producer: ú>©rZ   r6   s    r#   Ú__repr__zProducer.__repr__Ì   s   € Ø˜TŸ]™]˜O¨1Ð-Ð-r%   c                ó:   — | j                   | j                  «       fS r;   )Ú	__class__Ú__reduce_args__r6   s    r#   Ú
__reduce__zProducer.__reduce__Ï   s   € Ø�~‰~˜t×3Ñ3Ó5Ð5Ð5r%   c                óv   — d | j                   | j                  | j                  | j                  | j                  fS r;   )r[   r\   r]   ra   r^   r6   s    r#   ri   zProducer.__reduce_args__Ò   s4   € Ø�d—m‘m T×%5Ñ%5°t·±Ø×!Ñ! 4×#3Ñ#3ð5ð 	5r%   c                óf   — | j                   j                  r| j                   j                  «        yy)z­Declare the exchange.

        Note:
        ----
            This happens automatically at instantiation when
            the :attr:`auto_declare` flag is enabled.
        N)r[   ÚnameÚdeclarer6   s    r#   rn   zProducer.declareÖ   s&   € ð �=‰=×ÒØ�M‰M×!Ñ!Õ#ð r%   c                ó8   — |rt        || j                  |fi |¤ŽS y)z=Declare exchange if not already declared during this session.N)r   r*   )r"   ÚentityÚretryÚretry_policys       r#   r   zProducer.maybe_declareá   s"   € áÜ  ¨¯©°uÑMÀÑMÐMð r%   c                ó$  — | j                   }|€y	 |j                  j                  j                  }| j
                  }|�t        |t        «      st        |d|«      }nt        |j                  d|«      }t        |xr |«      S # t        $ r Y yw xY w)z@Return whether the active transport can defer batched publishes.Fr(   )
Ú
connectionÚ	transportÚ
implementsÚbatch_publishÚAttributeErrorrZ   Ú
isinstancer   r)   Úbool)r"   rt   Útransport_supportr*   Úconfigured_supports        r#   r(   zProducer.supports_batch_publishæ   s¥   € ð —_‘_ˆ
ØÐØð	Ø *× 4Ñ 4× ?Ñ ?× MÑ MÐð —-‘-ˆØÐ¤z°'¼>Ô'JÜ!(ØØ(Ø!ó"Ñô ")Ø×$Ñ$Ø(Ø!ó"Ðô
 Ð%Ò<Ð*<Ó=Ð=øô ò 	Ùð	ús   ‘ B Â	BÂBc                óz   — t        |t        «      st        |t        «      r|dk  rt        d«      ‚t	        | |«      S )aÀ  Group normal :meth:`publish` calls into transport-owned batches.

        Unsupported transports retain immediate publication.  A successful
        outermost context exit flushes pending messages; an exceptional exit
        discards messages that have not already been flushed.

        :param max_size: Maximum transport operations to buffer before an
            automatic flush. Must be a positive integer.
        :type max_size: int
        r   z#max_size must be a positive integer)ry   rz   ÚintÚ
ValueErrorrC   r!   s     r#   ÚbatchzProducer.batchÿ   s7   € ô �x¤Ô&Ü˜x¬Ô-°¸Q²ÜÐBÓCÐCÜ˜d HÓ-Ð-r%   c                ó¢   — t        ||«      r"|j                   ||xs |j                  «      fS | ||xs | j                  j                  «      fS r;   )ry   rm   Údelivery_moder[   )r"   r[   r‚   r   r   s        r#   Ú_delivery_detailszProducer._delivery_details  s^   € ô �h Ô)Ø—=‘=Ñ"5ØÒ7 ×!7Ñ!7ó#ð ð ð
 Ñ,ØÒ8˜TŸ]™]×8Ñ8ó
ð 
ð 	
r%   c                ó‚  — | j                   }|€g n|}|
€i n|
}
|€i n|}|€| j                  n|}|€| j                  n|}| j                  |xs | j                  |«      \  }|d<   |�t        t        |dz  «      «      |d<   | j                  ||	||||
«      \  }}}| j                  r?| j                  j                  r)| j                  |vr|j                  | j                  «       |rC| j                  j                  j                  |«        | j                  j                  | |fi |¤Ž} ||||||
||||||||||«      S )a´  Publish message to the specified exchange.

        Arguments:
        ---------
            body (Any): Message body.
            routing_key (str): Message routing key.
            delivery_mode (enum): See :attr:`delivery_mode`.
            mandatory (bool): Currently not supported.
            immediate (bool): Currently not supported.
            priority (int): Message priority. A number between 0 and 9.
            content_type (str): Content type. Default is auto-detect.
            content_encoding (str): Content encoding. Default is auto-detect.
            serializer (str): Serializer to use. Default is auto-detect.
            compression (str): Compression method to use.  Default is none.
            headers (Dict): Mapping of arbitrary headers to pass along
                with the message body.
            exchange (kombu.entity.Exchange, str): Override the exchange.
                Note that this exchange must have been declared.
            declare (Sequence[EntityT]): Optional list of required entities
                that must have been declared before publishing the message.
                The entities will be declared using
                :func:`~kombu.common.maybe_declare`.
            retry (bool): Retry publishing, or declaring entities if the
                connection is lost.
            retry_policy (Dict): Retry configuration, this is the keywords
                supported by :meth:`~kombu.Connection.ensure`.
            expiration (float): A TTL in seconds can be specified per message.
                Default is no expiration.
            timeout (float): Set timeout to wait maximum timeout second
                for message to publish.
            confirm_timeout (float): Set confirm timeout to wait maximum timeout second
                for message to confirm publishing if the channel is set to confirm publish mode.
            ``**properties`` (Any): Additional message properties, see AMQP spec.
        r‚   r   Ú
expiration)Ú_publishr\   r^   rƒ   r[   Ústrr~   Ú_preparera   rm   Úappendrt   Útransport_optionsÚupdateÚensure)r"   Úbodyr\   r‚   Ú	mandatoryr    ÚpriorityÚcontent_typeÚcontent_encodingr]   Úheadersr^   r[   rq   rr   rn   r…   ÚtimeoutÚconfirm_timeoutÚ
propertiesr†   Úexchange_names                         r#   r1   zProducer.publish  s\  € ðR —=‘=ˆà˜‘"¨WˆØ˜‘"¨WˆØ)Ð1‘r°|ˆØ*5Ð*=�d×&Ò&À;ˆØ*5Ð*=�d×&Ò&À;ˆà59×5KÑ5KØÒ%˜Ÿ™ }ó6
Ñ2ˆ�z /Ñ2ð Ð!Ü'*¬3¨z¸DÑ/@Ó+AÓ'BˆJ�|Ñ$à/3¯}©}Ø�*˜lÐ,<Ø˜ó0"Ñ,ˆˆlÐ,ð ×Ò §¡×!3Ò!3Ø�}‰} GÑ+à—‘˜tŸ}™}Ô-áØ�O‰O×-Ñ-×4Ñ4°\ÔBØ-�t—‘×-Ñ-¨d°HÑMÀÑMˆHÙØ�(˜LÐ*:Ø�Z ¨i¸Ø˜7 G¨_¸eÀ\ó
ð 	
r%   c                ó„  — |€i n|}| j                   }|j                  ||||||«      }|r| j                  }|D ]  } ||fd|i|¤Ž Œ |j                  d«      }t	        |t
        «      r|j                  |d<   |
|||	||dœ}t        | j                  dd «      }|� |j                  ||fi |¤ŽS  |j                  |fi |¤ŽS )Nrq   Úreply_to)r[   r\   rŽ   r    r“   r”   rK   )r*   Úprepare_messager   Úgetry   r   rm   r)   rL   r1   r0   )r"   r�   r�   r�   r‘   r’   r•   r\   rŽ   r    r[   rn   r“   r”   rq   rr   r*   r2   r   rp   r˜   Úpublish_kwargsr€   s                          r#   r†   zProducer._publishf  s÷   € ð *Ð1‘r°|ˆØ—,‘,ˆØ×)Ñ)Ø�(˜LØ˜g zó
ˆñ Ø ×.Ñ.ˆMØ!ò C�Ù˜fÑB¨EÐB°\ÓBðCð —>‘> *Ó-ˆÜ�h¤Ô&Ø%-§]¡]ˆJ�zÑ"à Ø&Ø"Ø"ØØ.ñ
ˆô ˜×)Ñ)¨9°dÓ;ˆØÐØ �5—=‘= ¨'ÑD°^ÑDÐDØ$ˆw×$Ñ$ WÑ?°Ñ?Ð?r%   c                óø   — | j                   }t        |t        «      r] |«       x}| _         | j                  j	                  |«       | j
                  r(|j                  d   j                  | j
                  «       |S )NÚbasic_return)rZ   ry   r   r[   rb   r_   ÚeventsÚadd©r"   r*   s     r#   Ú_get_channelzProducer._get_channel…  s\   € Ø—-‘-ˆÜ�gœ~Ô.Ù&-£iÐ/ˆG�d”mØ�M‰M× Ñ  Ô)Ø�~Š~Ø—‘˜~Ñ.×2Ñ2°4·>±>ÔBØˆr%   c                ó   — || _         y r;   re   r    s     r#   Ú_set_channelzProducer._set_channelŽ  s	   € Øˆ�r%   c                ó\  ‡— t        |«      r|Š‰| _        t        ˆfd„«      }t        |t        «      r|| _        | j                  |«      | _        y|| _        | j                  r2| j                  j                  d   j                  | j                  «       | j                  |«      | _        y)z*Revive the producer after connection loss.c                 ó   •— ‰ j                   S r;   )Údefault_channel)rt   s   €r#   ú<lambda>z!Producer.revive.<locals>.<lambda>˜  s   ø€ ¨Z×-GÑ-G€ r%   r�   N)	r   Ú__connection__r   ry   rZ   r[   r_   rž   rŸ   )r"   r*   rt   s     @r#   rb   zProducer.revive“  s…   ø€ ä˜Ô!Ø ˆJØ",ˆDÔÜ$Ó%GÓHˆGÜ�gœ~Ô.Ø#ˆDŒMØ ŸM™M¨'Ó2ˆD�Mð $ˆDŒMØ�~Š~Ø—‘×$Ñ$ ^Ñ4×8Ñ8¸¿¹ÔHØ ŸM™M¨'Ó2ˆD�Mr%   c                ó   — | S r;   rA   r6   s    r#   rM   zProducer.__enter__£  s   € Øˆr%   c                óÒ   — | j                   �K|�It        | j                   t        «      r/| j                   j                  j	                  | j                   «       | j                  «        y r;   )r¨   ry   r
   Ú_poolÚreplaceÚrelease)r"   rP   Úexc_valÚexc_tbs       r#   rU   zProducer.__exit__¦  sO   € ð ×ÑÐ*¨xÐ/CÜ˜$×-Ñ-Ô/?Ô@Ø×#Ñ#×)Ñ)×1Ñ1°$×2EÑ2EÔFà�‰�r%   c                 ó   — y r;   rA   r6   s    r#   r­   zProducer.release´  s   € Ør%   c                óÐ   — |s"|xs | j                   }t        ||¬«      \  }}}n*t        |t        «      r|sd}|j	                  |«      }n|sd}|rt        ||«      \  }|d<   |||fS )N)r]   zutf-8Úbinaryr^   )r]   r   ry   r‡   Úencoder	   )r"   r�   r]   r�   r‘   r^   r’   s          r#   rˆ   zProducer._prepare¹  s‚   € ñ Ø#Ò6 t§¡ˆJä˜4¨JÔ7ñˆ\Ð+Ùô ˜$¤Ô$Ù'Ø'.Ð$Ø—{‘{Ð#3Ó4‘ñ &Ø#+Ð áÜ+3°D¸+Ó+FÑ(ˆD�'˜-Ñ(à�\Ð#3Ð3Ð3r%   c                ó~   — 	 | j                   xs  | j                  j                  j                  S # t        $ r Y y w xY wr;   )r¨   r*   rt   Úclientrx   r6   s    r#   rt   zProducer.connectionÓ  s:   € ð	Ø×&Ñ&ÒH¨$¯,©,×*AÑ*A×*HÑ*HÐHøÜò 	Ùð	ús   ‚-0 °	<»<)NNNNNN©F)NNFFr   NNNNNNFNNNNN)NNFN©rP   ztype[BaseException] | Noner®   zBaseException | Noner¯   zTracebackType | NoneÚreturnÚNone)NNNNN)$r=   r>   r?   r@   r[   r\   r]   r^   ra   r_   r¨   r$   rf   rj   ri   rn   r   Úpropertyr(   ÚDEFAULT_BATCH_SIZEr€   r   r   rƒ   r1   r†   r¡   r£   r*   rb   rM   rU   r­   r<   rˆ   rt   rA   r%   r#   r   r   Ž   s/  „ ñð( €Hð €Kð €Jð €Kð €Lð €Ið €Nà;?ØAEØó'ò&.ò6ò5ò	$óNð
 ñ>ó ð>ð0 0ó .ð  9=Ø.AØ#+ó
ð =AØ;<ØEIØEJØJNØ $óH
ðX nró@ò>ò ñ �| \Ó2€Gò3ò ðà,ðð &ðð %ð	ð
 
óòð €Eà;?ØBFó4ð4 ñó ñr%   r   c                  óB  — e Zd ZdZeZdZdZdZdZdZ	dZ
dZdZdZdZ ed«      Z	 	 	 dd„Zed„ «       Zej&                  d„ «       Zd„ Zd	„ Zd
„ Zd„ Z	 	 	 	 	 	 	 	 dd„Zd„ Zd d„Zd„ Zd„ Zd„ ZeZd„ Zd„ Z d„ Z!d„ Z"d!d„Z#d"d„Z$d„ Z%dedfd„Z&d d„Z'd„ Z(d„ Z)ed„ «       Z*y)#r   a  Message consumer.

    Arguments:
    ---------
        channel (kombu.Connection, ChannelT): see :attr:`channel`.
        queues (Sequence[kombu.Queue]): see :attr:`queues`.
        no_ack (bool): see :attr:`no_ack`.
        auto_declare (bool): see :attr:`auto_declare`
        callbacks (Sequence[Callable]): see :attr:`callbacks`.
        on_message (Callable): See :attr:`on_message`
        on_decode_error (Callable): see :attr:`on_decode_error`.
        prefetch_count (int): see :attr:`prefetch_count`.
    NTr   c                óp  — || _         t        |xs g «      | _        |€| j                  n|| _        |€| j                  xs g n|| _        || _        |
| _        i | _        i | _        |�|| _	        |�|| _
        t        |«      | _        |	| _        | j                   r| j                  | j                   «       y y r;   )r*   r   ÚqueuesÚno_ackÚ	callbacksÚ
on_messageÚ
tag_prefixÚ_active_tagsÚ_active_queue_no_ackra   Úon_decode_errorr   ÚacceptÚprefetch_countrb   )r"   r*   r¾   r¿   ra   rÀ   rÅ   rÁ   rÆ   rÇ   rÂ   s              r#   r$   zConsumer.__init__3  s±   € ð ˆŒÜ  ¢¨2Ó.ˆŒØ%+ ^�d—k’k¸ˆŒØ2;Ð2C˜$Ÿ.™.Ò.©BØ(ð 	Œà$ˆŒØ$ˆŒØˆÔØ$&ˆÔ!ØÐ#Ø ,ˆDÔØÐ&Ø#2ˆDÔ Ü,¨VÓ4ˆŒØ,ˆÔà�<Š<Ø�K‰K˜Ÿ™Õ%ð r%   c                óH   — t        | j                  j                  «       «      S r;   )ÚlistÚ_queuesÚvaluesr6   s    r#   r¾   zConsumer.queuesI  s   € ä�D—L‘L×'Ñ'Ó)Ó*Ð*r%   c                óN   — |D �ci c]  }|j                   |“Œ c}| _        y c c}w r;   )rm   rÊ   )r"   r¾   Úqs      r#   r¾   zConsumer.queuesM  s   € à+1Ö2 a˜Ÿ™ ™	Ò2ˆ�ùÒ2s   …"c                ót  — | j                   j                  «       }| j                  j                  «        | j                   j                  «        t	        |«      x}| _        t        | j                  j                  «       «      D ]]  \  }}| j                  j                  |d«        || j
                  «      x}| j                  |j                  <   |j                  |«       Œ_ | j                  r| j                  «        | j                  �| j                  | j                  ¬«       | j!                  |«       y)z&Revive consumer after connection loss.N)rÇ   )rÄ   ÚcopyrÃ   Úclearr   r*   rÉ   rÊ   ÚitemsÚpoprm   rb   ra   rn   rÇ   ÚqosÚ_consume_previously_active)r"   r*   Úprevious_no_ackÚqnameÚqueues        r#   rb   zConsumer.reviveQ  sô   € à×3Ñ3×8Ñ8Ó:ˆØ×Ñ×ÑÔ!Ø×!Ñ!×'Ñ'Ô)Ü!.¨wÓ!7Ð7ˆ�$”,ä  §¡×!3Ñ!3Ó!5Ó6ò 	"‰LˆE�5à�L‰L×Ñ˜U DÔ)Ù/4°T·\±\Ó/BÐBˆE�D—L‘L §¡Ñ,Ø�L‰L˜Õ!ð		"ð ×ÒØ�L‰LŒNà×ÑÐ*Ø�H‰H D×$7Ñ$7ˆHÔ8ð 	×'Ñ'¨Õ8r%   c                ób   — | j                   j                  «       D ]  }|j                  «        Œ y)z²Declare queues, exchanges and bindings.

        Note:
        ----
            This is done automatically at instantiation
            when :attr:`auto_declare` is set.
        N)rÊ   rË   rn   ©r"   r×   s     r#   rn   zConsumer.declareh  s)   € ð —\‘\×(Ñ(Ó*ò 	ˆEØ�M‰M�Oñ	r%   c                ó:   — | j                   j                  |«       y)a%  Register a new callback to be called when a message is received.

        Note:
        ----
            The signature of the callback needs to accept two arguments:
            `(body, message)`, which is the decoded message body
            and the :class:`~kombu.Message` instance.
        N)rÀ   r‰   )r"   Úcallbacks     r#   Úregister_callbackzConsumer.register_callbacks  s   € ð 	�‰×Ñ˜hÕ'r%   c                ó&   — | j                  «        | S r;   )Úconsumer6   s    r#   rM   zConsumer.__enter__~  s   € Ø�‰ŒØˆr%   c                óú   — | j                   r`| j                   j                  rI| j                   j                  j                  j                  }t	        ||«      s	 | j                  «        y y y y # t        $ r Y y w xY wr;   )r*   rt   rµ   Úconnection_errorsry   ÚcancelÚ	Exception)r"   rP   r®   r¯   Úconn_errorss        r#   rU   zConsumer.__exit__‚  sj   € ð �<Š<˜DŸL™L×3Ò3ØŸ,™,×1Ñ1×8Ñ8×JÑJˆKÜ˜g {Ô3ðØ—K‘K•Mð 4ð 4ˆ<øô
 !ò Ùðús   ÁA. Á.	A:Á9A:c                ó”   —  || j                   «      }| j                  r|j                  «        || j                  |j                  <   |S )zÓAdd a queue to the list of queues to consume from.

        Note:
        ----
            This will not start consuming from the queue,
            for that you will have to call :meth:`consume` after.
        )r*   ra   rn   rÊ   rm   rÙ   s     r#   Ú	add_queuezConsumer.add_queue�  s;   € ñ �d—l‘lÓ#ˆØ×ÒØ�M‰MŒOØ#(ˆ�‰�U—Z‘ZÑ Øˆr%   c                ó²   — |€| j                   n|}| j                  | j                  j                  «       D �ci c]  }|j                  |“Œ c}«       yc c}w )aV  Start consuming messages.

        Can be called multiple times, but note that while it
        will consume from new queues added since the last call,
        it will not cancel consuming from removed queues (
        use :meth:`cancel_by_queue`).

        Arguments:
        ---------
            no_ack (bool): See :attr:`no_ack`.
        N)r¿   Ú_consume_queuesrÊ   rË   rm   )r"   r¿   r×   s      r#   rÞ   zConsumer.consumež  sH   € ð !' �—’°FˆØ×ÑØ-1¯\©\×-@Ñ-@Ó-BÖC EˆU�Z‰Z˜ÑÒCõ	
ùÚCs   ¸Ac                ó&   — | j                  |«       y)a  Start consuming only from the given, previously active queues.

        Unlike :meth:`consume`, this will not start consuming from
        queues that were registered (e.g. via :meth:`add_queue`) but
        never actually consumed from, and it restores each queue's
        own effective ``no_ack`` value instead of applying one value
        to every queue.

        Arguments:
        ---------
            active_no_ack (dict): Mapping of queue name to the
                ``no_ack`` value it was consumed with.
        N)rç   )r"   Úactive_no_acks     r#   rÔ   z#Consumer._consume_previously_active¯  s   € ð 	×Ñ˜]Õ+r%   c                ó&  — | j                   j                  «       D �cg c]  }|j                  |v sŒ|‘Œ }}|sy |d d |d   }}|D ]#  }| j                  |||j                     d¬«       Œ% | j                  |||j                     d¬«       y c c}w )NéÿÿÿÿT©r¿   ÚnowaitF)rÊ   rË   rm   Ú_basic_consume)r"   Úno_ack_by_queuerÍ   r¾   ÚHÚTr×   s          r#   rç   zConsumer._consume_queuesÀ  s«   € à—|‘|×*Ñ*Ó,ö
Ø°·±¸/Ò0IŠAð
ˆð 
ñ ØØ�c�rˆ{˜F 2™Jˆ1ˆØò 	ˆEØ×ÑØ˜o¨e¯j©jÑ9À$ð  õ ð	ð 	×ÑØ�o a§f¡fÑ-°eð 	õ 	
ùò
s
   �B±Bc                óæ   — | j                   j                  }| j                  j                  «       D ]
  } ||«       Œ | j                  j	                  «        | j
                  j	                  «        y)zÜEnd all active queue consumers.

        Note:
        ----
            This does not affect already delivered messages, but it does
            mean the server will not send any more messages for this consumer.
        N)r*   Úbasic_cancelrÃ   rË   rÐ   rÄ   )r"   rá   Útags      r#   rá   zConsumer.cancelÏ  s\   € ð —‘×*Ñ*ˆØ×$Ñ$×+Ñ+Ó-ò 	ˆCÙ�3�Kð	à×Ñ×ÑÔ!Ø×!Ñ!×'Ñ'Õ)r%   c                ó~  — t        |t        «      r|j                  n|}| j                  j	                  |d«       	 | j
                  j	                  |«      }| j                  j                  |«       | j                  j	                  |d«       y# t        $ r Y Œ(w xY w# | j                  j	                  |d«       w xY w)zCancel consumer by queue name.N)
ry   r   rm   rÄ   rÒ   rÃ   r*   ró   ÚKeyErrorrÊ   )r"   r×   rÖ   rô   s       r#   Úcancel_by_queuezConsumer.cancel_by_queueß  sš   € ä(¨´Ô6�—
’
¸EˆØ×!Ñ!×%Ñ% e¨TÔ2ð	*Ø×#Ñ#×'Ñ'¨Ó.ˆCð �L‰L×%Ñ% cÔ*à�L‰L×Ñ˜U DÕ)øô ò 	Ùð	ûð
 �L‰L×Ñ˜U DÕ)ús)   ¼B ÁB Â	BÂB ÂBÂB ÂB<c                óZ   — |}t        |t        «      r|j                  }|| j                  v S )z8Return :const:`True` if currently consuming from queue'.)ry   r   rm   rÃ   )r"   r×   rm   s      r#   Úconsuming_fromzConsumer.consuming_fromì  s+   € àˆÜ�eœUÔ#Ø—:‘:ˆDØ�t×(Ñ(Ð(Ð(r%   c                óV   — t        d„ | j                  j                  «       D «       «      S )z™Purge messages from all queues.

        Warning:
        -------
            This will *delete all ready messages*, there is no undo operation.
        c              3  ó<   K  — | ]  }|j                  «       –— Œ y ­wr;   )Úpurge)Ú.0r×   s     r#   ú	<genexpr>z!Consumer.purge.<locals>.<genexpr>ú  s   è ø€ ÒD U�5—;‘;—=ÑDùs   ‚)ÚsumrÊ   rË   r6   s    r#   rü   zConsumer.purgeó  s"   € ô ÑD¨d¯l©l×.AÑ.AÓ.CÔDÓDÐDr%   c                ó:   — | j                   j                  |«       y)a’  Enable/disable flow from peer.

        This is a simple flow-control mechanism that a peer can use
        to avoid overflowing its queues or otherwise finding itself
        receiving more messages than it can process.

        The peer that receives a request to stop sending content
        will finish sending the current content (if any), and then wait
        until flow is reactivated.
        N)r*   Úflow)r"   rI   s     r#   r  zConsumer.flowü  s   € ð 	�‰×Ñ˜&Õ!r%   c                ó<   — | j                   j                  |||«      S )a  Specify quality of service.

        The client can request that messages should be sent in
        advance so that when the client finishes processing a message,
        the following message is already held locally, rather than needing
        to be sent down the channel. Prefetching gives a performance
        improvement.

        The prefetch window is Ignored if the :attr:`no_ack` option is set.

        Arguments:
        ---------
            prefetch_size (int): Specify the prefetch window in octets.
                The server will send a message in advance if it is equal to
                or smaller in size than the available prefetch size (and
                also falls within other prefetch limits). May be set to zero,
                meaning "no specific limit", although other prefetch limits
                may still apply.

            prefetch_count (int): Specify the prefetch window in terms of
                whole messages.

            apply_global (bool): Apply new settings globally on all channels.
        )r*   Ú	basic_qos)r"   Úprefetch_sizerÇ   Úapply_globals       r#   rÓ   zConsumer.qos	  s#   € ð2 �|‰|×%Ñ% mØ&4Ø&2ó4ð 	4r%   c                ó:   — | j                   j                  |¬«      S )aÑ  Redeliver unacknowledged messages.

        Asks the broker to redeliver all unacknowledged messages
        on the specified channel.

        Arguments:
        ---------
            requeue (bool): By default the messages will be redelivered
                to the original recipient. With `requeue` set to true, the
                server will attempt to requeue the message, potentially then
                delivering it to an alternative subscriber.
        )Úrequeue)r*   Úbasic_recover)r"   r  s     r#   ÚrecoverzConsumer.recover&  s   € ð �|‰|×)Ñ)°'Ð)Ó:Ð:r%   c                ón   — | j                   }|st        d«      ‚|D �cg c]  } |||«      ‘Œ c} yc c}w )aƒ  Method called when a message is received.

        This dispatches to the registered :attr:`callbacks`.

        Arguments:
        ---------
            body (Any): The decoded message body.
            message (~kombu.Message): The message instance.

        Raises
        ------
            NotImplementedError: If no consumer callbacks have been
                registered.
        z$Consumer does not have any callbacksN)rÀ   ÚNotImplementedError)r"   r�   r2   rÀ   rÛ   s        r#   ÚreceivezConsumer.receive5  s4   € ð —N‘Nˆ	ÙÜ%Ð&LÓMÐMØ1:Ö; X‰�$˜Õ	 Ô;ùÒ;s   ž2c                ó  — | j                   j                  |j                  «      }|€Z|€|j                  n|}| j	                  ||«      }|| j
                  |j                  <   |j                  || j                  ||¬«       |S )Nrì   )rÃ   rš   rm   r¿   Ú_add_tagrÄ   rÞ   Ú_receive_callback)r"   r×   Úconsumer_tagr¿   rí   rô   s         r#   rî   zConsumer._basic_consumeI  sy   € à×Ñ×#Ñ# E§J¡JÓ/ˆØˆ;Ø%+ ^�U—\’\¸ˆFØ—-‘-  |Ó4ˆCØ4:ˆD×%Ñ% e§j¡jÑ1Ø�M‰M˜#˜t×5Ñ5Ø!'°ð ô 8àˆ
r%   c                óž   — |xs/ dj                  | j                  t        | j                  «      «      }|| j                  |j
                  <   |S )Nz{}{})ÚformatrÂ   ÚnextÚ_tagsrÃ   rm   )r"   r×   r  rô   s       r#   r  zConsumer._add_tagT  sB   € Øò /˜fŸm™mØ�O‰OœT $§*¡*Ó-ó/ˆà(+ˆ×Ñ˜%Ÿ*™*Ñ%Øˆ
r%   c                ó¨  — | j                   }| j                  | j                  d }}}	 t        |dd «      }|r ||«      }|�||_         |j                  r|j                  | j                  «      S |rd n|j                  «       }|r ||«      S | j                  ||«      S # t        $ r)}| j                  s‚ | j                  ||«       Y d }~y d }~ww xY w)NÚmessage_to_python)
rÆ   rÁ   r*   r)   ÚerrorsÚ_reraise_errorrÅ   Údecoder  râ   )r"   r2   rÆ   Úon_mr*   ÚdecodedÚm2prT   s           r#   r  zConsumer._receive_callbackZ  sË   € Ø—‘ˆØ!%§¡°$·,±,À�wˆgˆð	MÜ˜'Ð#6¸Ó=ˆCÙÙ˜g›,�ØÐ!Ø!'�”Ø�~Š~Ø×-Ñ-¨d×.BÑ.BÓCÐCÙ"‘d¨¯©Ó(8ˆGñ %)‘4˜“=ÐL¨d¯l©l¸7ÀGÓ.LÐLøô ò 	/Ø×'Ò'ØØ× Ñ  ¨#×.Ñ.ûð	/ús   ¨AB Á/B Â	CÂ(CÃCc                óN   — dt        | «      j                  › d| j                  › d�S )Nú<z: rd   )Útyper=   r¾   r6   s    r#   rf   zConsumer.__repr__m  s&   € Ø”4˜“:×&Ñ&Ð' r¨$¯+©+¨°aÐ8Ð8r%   c                ób   — 	 | j                   j                  j                  S # t        $ r Y y w xY wr;   )r*   rt   rµ   rx   r6   s    r#   rt   zConsumer.connectionp  s/   € ð	Ø—<‘<×*Ñ*×1Ñ1Ð1øÜò 	Ùð	ús   ‚" ¢	.­.)	NNNNNNNNNr·   r;   )r   r   Fr¶   )+r=   r>   r?   r@   r   r*   r¾   r¿   ra   rÀ   rÁ   rÅ   rÆ   rÇ   rÊ   r   r  r$   rº   Úsetterrb   rn   rÜ   rM   rU   rå   rÞ   rÔ   rç   rá   r<   r÷   rù   rü   r  rÓ   r	  r  rî   r  r  rf   rt   rA   r%   r#   r   r   Û  sN  „ ñð *Ðð €Gð €Fð €Fð €Lð €Ið$ €Jð €Oð €Fð €Nð €Gá�!‹H€EàGKØBFØ>Bó&ð, ñ+ó ð+ð ‡]�]ñ3ó ð3ò9ò.	ò	(òðà,ðð &ðð %ð	ð
 
óòó
ò",ò"
ò*ð €Eò*ò)òEò"ó4ó:;ò<ð( 26Ø$¨Tó	óòMò&9ð ñó ñr%   r   N)%r@   Ú
__future__r   Ú	itertoolsr   Ú	threadingr   Útypingr   Úcommonr   r^   r	   rt   r
   r   r   rp   r   r   r   Ú
exceptionsr   Úserializationr   r   Úutils.functionalr   r   Útypesr   Ú__all__r»   r   rC   r   r   rA   r%   r#   ú<module>r,     so   ðÙ %å "å Ý Ý  å !Ý !ß FÑ Fß 8Ñ 8Ý )ß 8ß 8áÝ#à
7€àÐ ÷0!ñ 0!÷f?ñ ?÷DJñ J÷Z
Zò Zr%   