
     hW                         d 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.    N   )
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	   a`  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                I/var/www/html/Sam_Eipo/venv/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'   r5   r2   s      r*   ackzMessage.ackc   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)Nr4   zCouldn't ack %r, reason:%rTr#   )r;   BrokenPipeErrorcriticalr   )r'   loggerr   r5   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'   r@   r   rD   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.
        Nr1   r3   rC   r   r   r   r8   r9   basic_rejectr   r   )r'   rD   s     r*   rE   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 )a.  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.
        Nr1   r3   TrC   r   rH   r'   s    r*   rD   zMessage.requeue   s     <((@B B B 	((ELL    	!!$"3T!BBB rJ   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   _decoderL   s    r*   decodezMessage.decode   s(     " 	1"&,,..D""rJ   c                 P    t          | j        | j        | j        | j                  S )N)r   )r   r   r   r   r   rL   s    r*   rN   zMessage._decode   s0    TY 1*4;@ @ @ 	@rJ   c                     | j         t          v S )z1Set to true if the message has been acknowledged.)r   
ACK_STATESrL   s    r*   r8   zMessage.acknowledged   s     {j((rJ   c                 F    | j         r| j         n|                                 S )zThe decoded message body.)r   rO   rL   s    r*   payloadzMessage.payload   s"     '+&9Lt""t{{}}LrJ   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)rV   rW   exchangerouting_key)rX   rY   )stater   r   body_lengthr   r   )r9   rW   __name__idr   r   r   r   r   lenr   r   r   rL   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  , , ,
 
 	
rJ   )
NNNNNNNNNN)N)F)r\   
__module____qualname____doc__r   r   IS_PYPY	__slots__r+   r/   r;   rA   rF   rE   rD   rO   rN   propertyr8   rT   r_    rJ   r*   r	   r	      s@        > *F 

	 04IM;?&*   >          6	C 	C 	C 	CC C C C! ! ! !&! ! !*# # #@ @ @ ) ) X) M M XM
 
 
 
 
rJ   r	   )rb   r"   r   r   
exceptionsr   r   serializationr   utils.functionalr   __all__rR   hasattrrc   r	   rf   rJ   r*   <module>rl      s      



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

'#*
+
+S
 S
 S
 S
 S
 S
 S
 S
 S
 S
rJ   