
    ^f                        d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZ d	Zh d
Z eed          Z G d d          ZdS )zMessage class.    )annotationsN   )
decompress)MessageStateErrorreraise)loads)
dictfilter)Message>   ACKREJECTEDREQUEUEDpypy_version_infoc                      e Zd ZdZeZdZesdZ	 	 	 	 ddZddZ	ddZ
ddZdd	Zdd
Zd Zd Zd Zed             Zed             Zd ZdS )r
   au  Base class for received messages.

    Keyword Arguments:
    -----------------
        channel (ChannelT): If message was received, this should be the
            channel that the message was received on.

        body (str): Message body.

        delivery_mode (bool): Set custom delivery mode.
            Defaults to :attr:`delivery_mode`.

        priority (int): Message priority, 0 to broker configured
            max priority, where higher is better.

        content_type (str): The messages content_type.  If content_type
            is set, no serialization occurs as it is assumed this is either
            a binary object, or you've done your own serialization.
            Leave blank if using built-in serialization as our library
            properly sets content_type.

        content_encoding (str): The character set in which this object
            is encoded. Use "binary" if sending in raw binary objects.
            Leave blank if using built-in serialization as our library
            properly sets content_encoding.

        properties (Dict): Message properties.

        headers (Dict): Message headers.
    N)_statechanneldelivery_tagcontent_typecontent_encodingdelivery_infoheaders
propertiesbody_decoded_cacheaccept__dict__c                   |si n|}| j         g n| j         | _         |
| _        || _        || _        || _        || _        |pi | _        |pi | _        d | _        d| _	        |	| _
        | j                            d          }| j         sO|rM	 t          ||          }n;# t          $ r. | j                             t          j                               Y nw xY w| j         si|rgt#          |t$                    rR	 |                    |          }n;# t          $ r. | j                             t          j                               Y nw xY w|| _        d S )NRECEIVEDcompression)errorsr   r   r   r   r   r   r   r   r   r   getr   	Exceptionappendsysexc_info
isinstancestrencoder   )selfr   r   r   r   r   r   r   
postencoder   r   kwargsr   s                ?/var/www/html/env/lib/python3.11/site-packages/kombu/message.py__init__zMessage.__init__>   sw    #0B] K/bbT[(( 0*}"$*" l&&}55{ 	3{ 	33!$44 3 3 3""3<>>222223 { 	3z 	3js.C.C 	33{{:.. 3 3 3""3<>>222223			s$   
B 5CC5D 5EEc                ~    	 t          | j        d           d S # t          $ r}|s  || |           Y d }~d S d }~ww xY w)Nr   )r   r   r!   )r(   callbackexcs      r+   _reraise_errorzMessage._reraise_error]   sl    	 T[^$$$$ 	  	  	  HT3	 s    
<7<Fc                b   | j         |                     d          | j         j        /	 | j        d         }|| j         j        v rdS n# t          $ r Y nw xY w| j        r(|                     d                    |                     | j                             | j        |           d| _	        dS )zAcknowledge this message as being processed.

        This will remove the message from the queue.

        Raises
        ------
            MessageStateError: If the message has already been
                acknowledged/requeued/rejected.
        N.This message does not have a receiving channelconsumer_tag3Message already acknowledged with state: {0._state}multipler   )
r   r   no_ack_consumersr   KeyErroracknowledgedformat	basic_ackr   r   )r(   r6   r3   s      r+   ackzMessage.acke   s     <((@B B B<(4#1.A  4<#@@@F A    
  	((ELL    	t08DDDs   A 
AAc                    	 |                      |           d S # t          $ r$}|                    d| j        |d            d }~w|$ r)}|                    d| j        |d           Y d }~d S d }~ww xY w)Nr5   zCouldn't ack %r, reason:%rTr$   )r<   BrokenPipeErrorcriticalr   )r(   loggerr   r6   r/   s        r+   ack_log_errorzMessage.ack_log_error   s    	CHHhH''''' 	 	 	OO8 -sT  C C C 	C 	C 	COO8 -sT  C C C C C C C C C	Cs     
A4AA4A//A4c                    	 |                      |           d S # |$ r)}|                    d| j        |d           Y d }~d S d }~ww xY w)NrequeuezCouldn't reject %r, reason: %rTr>   )rejectr@   r   )r(   rA   r   rE   r/   s        r+   reject_log_errorzMessage.reject_log_error   s    	CKKK((((( 	C 	C 	COO< -sT  C C C C C C C C C	Cs    AAAc                    | j         |                     d          | j        r(|                     d                    |                     | j                             | j        |           d| _        dS )zReject this message.

        The message will be discarded by the server.

        Raises
        ------
            MessageStateError: If the message has already been
                acknowledged/requeued/rejected.
        Nr2   r4   rD   r   r   r   r9   r:   basic_rejectr   r   )r(   rE   s     r+   rF   zMessage.reject   s     <((@B B B 	((ELL    	!!$"3W!EEE     c                    | j         |                     d          | j        r(|                     d                    |                     | j                             | j        d           d| _        dS )aL  Reject this message and put it back on the queue.

        Warning:
        -------
            You must not use this method as a means of selecting messages
            to process.

        Raises
        ------
            MessageStateError: If the message has already been
                acknowledged/requeued/rejected.
        Nr2   r4   TrD   r   rI   r(   s    r+   rE   zMessage.requeue   s     <((@B B B 	((ELL    	!!$"3T!BBB rK   c                P    | j         s|                                 | _         | j         S )zDeserialize the message body.

        Returning the original python structure sent by the publisher.

        Note:
        ----
            The return value is memoized, use `_decode` to force
            re-evaluation.
        )r   _decoderM   s    r+   decodezMessage.decode   s(     " 	1"&,,..D""rK   c                P    t          | j        | j        | j        | j                  S )N)r   )r   r   r   r   r   rM   s    r+   rO   zMessage._decode   s0    TY 1*4;@ @ @ 	@rK   c                    | j         t          v S )z1Set to true if the message has been acknowledged.)r   
ACK_STATESrM   s    r+   r9   zMessage.acknowledged   s     {j((rK   c                F    | j         r| j         n|                                 S )zThe decoded message body.)r   rP   rM   s    r+   payloadzMessage.payload   s"     '+&9Lt""t{{}}LrK   c                   d                     t          |           j        t          |           t	          | j        | j        | j        | j        t          | j                  nd t	          | j
                            d          | j
                            d                    t	          | j                            d          | j                            d                                        S )	Nz&<{} object at {:#x} with details {!r}>correlation_idtype)rW   rX   exchangerouting_key)rY   rZ   )stater   r   body_lengthr   r   )r:   rX   __name__idr	   r   r   r   r   lenr   r    r   rM   s    r+   __repr__zMessage.__repr__   s    7>>JJD:k!.!..2i.CC	NNN%#'?#6#67G#H#H,,V44   )!/33J?? $ 2 6 6} E E  , , ,
 
 	
rK   )
NNNNNNNNNN)N)F)r]   
__module____qualname____doc__r   r   IS_PYPY	__slots__r,   r0   r<   rB   rG   rF   rE   rP   rO   propertyr9   rU   r`    rK   r+   r
   r
      s@        > *F 

	 04IM;?&*   >          8	C 	C 	C 	CC C C C! ! ! !(! ! !.# # #@ @ @ ) ) X) M M XM
 
 
 
 
rK   r
   )rc   
__future__r   r#   r   r   
exceptionsr   r   serializationr   utils.functionalr	   __all__rS   hasattrrd   r
   rg   rK   r+   <module>rn      s      " " " " " " 



 # # # # # # 2 2 2 2 2 2 2 2             ( ( ( ( ( (
,,,

'#*
+
+X
 X
 X
 X
 X
 X
 X
 X
 X
 X
rK   