HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/kombu/__pycache__/message.cpython-310.pyc
o

'we��@stdZddlmZddlZddlmZddlmZmZddl	m
Z
ddlmZd	Z
hd
�Zeed�ZGdd
�d
�ZdS)zMessage class.�)�annotationsN�)�
decompress)�MessageStateError�reraise)�loads)�
dictfilter)�Message>�ACK�REJECTED�REQUEUED�pypy_version_infoc@s�eZdZdZeZdZesdZ				ddd�Zddd�Z	dd	d
�Z
ddd�Zdd
d�Zddd�Z
dd�Zdd�Zdd�Zedd��Zedd��Zdd�ZdS) r	auBase 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
Ks�|sin|}|jdur
gn|j|_|
|_||_||_||_||_|p#i|_|p(i|_d|_d|_	|	|_
|j�d�}|jsW|rWzt||�}Wnt
yV|j�t���Ynw|jsz|rzt|t�rzz|�|�}Wnt
yy|j�t���Ynw||_dS)N�RECEIVED�compression)�errorsrrrrrrrrrr�getr�	Exception�append�sys�exc_info�
isinstance�str�encoder)
�selfrrrrrrr�
postencoderr�kwargsr�r(�F/home/arjun/projects/env/lib/python3.10/site-packages/kombu/message.py�__init__>s4


��
zMessage.__init__c
CsLz
t|jd�WdSty%}z|s�|||�WYd}~dSd}~ww)Nr)rrr)r%�callback�excr(r(r)�_reraise_error]s��zMessage._reraise_errorFcCs�|jdur
|�d��|jjdur)z|jd}Wn	ty Yn	w||jjvr)dS|jr4|�d�|���|jj|j|d�d|_	dS)z�Acknowledge 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_tag�3Message already acknowledged with state: {0._state}��multipler
)
rr�no_ack_consumersr�KeyError�acknowledged�format�	basic_ackrr)r%r2r/r(r(r)�ackes(

����
zMessage.ackc
Cszz	|j|d�WdSty }z|jd|j|dd��d}~w|y<}z|jd|j|dd�WYd}~dSd}~ww)Nr1zCouldn't ack %r, reason:%rT�r!)r8�BrokenPipeError�criticalr)r%�loggerrr2r,r(r(r)�
ack_log_error�s�����zMessage.ack_log_errorc
CsNz	|j|d�WdS|y&}z|jd|j|dd�WYd}~dSd}~ww)N��requeuezCouldn't reject %r, reason: %rTr9)�rejectr;r)r%r<rr?r,r(r(r)�reject_log_error�s���zMessage.reject_log_errorcCsF|jdur
|�d��|jr|�d�|���|jj|j|d�d|_dS)z�Reject this message.

        The message will be discarded by the server.

        Raises
        ------
            MessageStateError: If the message has already been
                acknowledged/requeued/rejected.
        Nr.r0r>r�rrr5r6�basic_rejectrr)r%r?r(r(r)r@�s

���
zMessage.rejectcCsF|jdur
|�d��|jr|�d�|���|jj|jdd�d|_dS)aLReject 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.
        Nr.r0Tr>rrB�r%r(r(r)r?�s

���
zMessage.requeuecCs|js|��|_|jS)z�Deserialize 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�_decoderDr(r(r)�decode�s

zMessage.decodecCst|j|j|j|jd�S)N)r)rrrrrrDr(r(r)rE�s
�zMessage._decodecCs
|jtvS)z1Set to true if the message has been acknowledged.)r�
ACK_STATESrDr(r(r)r5�s
zMessage.acknowledgedcCs|jr|jS|��S)zThe decoded message body.)rrFrDr(r(r)�payload�szMessage.payloadcCsrd�t|�jt|�t|j|j|j|jdurt	|j�ndt|j
�d�|j
�d�d�t|j�d�|j�d�d�d��S)	Nz&<{} object at {:#x} with details {!r}>�correlation_id�type)rIrJ�exchange�routing_key)rKrL)�staterr�body_lengthrr)
r6rJ�__name__�idrrrrr�lenrrrrDr(r(r)�__repr__�s 

�

���zMessage.__repr__)
NNNNNNNNNN)N)F)rO�
__module__�__qualname__�__doc__rr�IS_PYPY�	__slots__r*r-r8r=rAr@r?rFrE�propertyr5rHrRr(r(r(r)r	s0
�






r	)rU�
__future__rr rr�
exceptionsrr�
serializationr�utils.functionalr�__all__rG�hasattrrVr	r(r(r(r)�<module>s