HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/local/lib/python3.9/site-packages/amqp/__pycache__/connection.cpython-39.pyc
a

X>h�k�@s>dZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZm
Z
ddlmZdd	lmZdd
lmZmZmZmZmZmZmZmZmZddlmZmZddlm Z zdd
l!m"Z"Wn"e#y�Gdd�de$�Z"Yn0dZ%d�&�Z'dZ(e�)d�Z*e�)d�Z+ded�Z,dddd�Z-Gdd�de�Z.dS)zAMQP Connections.�N)�array)�	monotonic)�ensure_promise�)�__version__�sasl�spec)�AbstractChannel)�Channel)	�AMQPDeprecationWarning�ChannelError�ConnectionError�ConnectionForced�
MessageNacked�RecoverableChannelError�RecoverableConnectionError�
ResourceError�error_for_code)�
frame_handler�frame_writer��	Transport)�SSLErrorc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�9/usr/local/lib/python3.9/site-packages/amqp/connection.pyrsrz�The .{attr} attribute on the connection was accessed before
the connection was established.  This is supported for now, but will
be deprecated in amqp 2.2.0.

Since amqp 2.0 you have to explicitly call Connection.connect()
before using the connection.
zP
Start from server, version: %d.%d, properties: %s, mechanisms: %s, locales: %s
)�
ConnectionZamqpz)amqp.connection.Connection.heartbeat_tickzpy-amqp)�productZproduct_versionT)Zconsumer_cancel_notifyzconnection.blockedZauthentication_failure_closecs�eZdZdZeZeZeZdZ	dZ
dZdZdZ
dZdZdZdZe�ejjd�e�ejj�e�ejjd�e�ejjd�e�ejjd�e�ejj�e�ejj�e�ejj�hZdd	�eD�ZejjejjfZee j!e"e#fZ$e%fZ&e'e(e j!e"e#fZ)e*fZ+d
dddddd
ddddddddddddddde,e-f�fdd�	Z.dd�Z/dd�Z0dd�Z1d`dd�Z2dd�Z3dadd�Z4dd�Z5e6d d!��Z7e7j8d"d!��Z7e6d#d$��Z9e9j8d%d$��Z9e6d&d'��Z-e-j8d(d'��Z-dbd*d+�Z:d,d-�Z;dcd.d/�Z<ddd1d2�Z=d3d4�Z>ded5d6�Z?e6d7d8��Z@d9d:�ZAd;d<�ZBd=d>�ZCdfd?d@�ZDdAdB�ZEdgdCdD�ZFdhdEdF�ZGdGdH�ZHdidKdL�ZIdMdN�ZJdOdP�ZKdQdR�ZLdSdT�ZMdUdV�ZNdWdX�ZOdjdZd[�ZPe6d\d]��ZQe6d^d_��ZR�ZSS)kra�AMQP Connection.

    The connection class provides methods for a client to establish a
    network connection to a server, and for both peers to operate the
    connection thereafter.

    GRAMMAR::

        connection          = open-connection *use-connection close-connection
        open-connection     = C:protocol-header
                              S:START C:START-OK
                              *challenge
                              S:TUNE C:TUNE-OK
                              C:OPEN S:OPEN-OK
        challenge           = S:SECURE C:SECURE-OK
        use-connection      = *channel
        close-connection    = C:CLOSE S:CLOSE-OK
                            / S:CLOSE C:CLOSE-OK
    Create a connection to the specified host, which should be
    a 'host[:port]', such as 'localhost', or '1.2.3.4:5672'
    (defaults to 'localhost', if a port is not specified then
    5672 is used)

    Authentication can be controlled by passing one or more
    `amqp.sasl.SASL` instances as the `authentication` parameter, or
    setting the `login_method` string to one of the supported methods:
    'GSSAPI', 'EXTERNAL', 'AMQPLAIN', or 'PLAIN'.
    Otherwise authentication will be performed using any supported method
    preferred by the server. Userid and passwords apply to AMQPLAIN and
    PLAIN authentication, whereas on GSSAPI only userid will be used as the
    client name. For EXTERNAL authentication both userid and password are
    ignored.

    The 'ssl' parameter may be simply True/False, or
    a dictionary of options to pass to :class:`ssl.SSLContext` such as
    requiring certain certificates. For details, refer ``ssl`` parameter of
    :class:`~amqp.transport.SSLTransport`.

    The "socket_settings" parameter is a dictionary defining tcp
    settings which will be applied as socket options.

    When "confirm_publish" is set to True, the channel is put to
    confirm mode. In this mode, each published message is
    confirmed using Publisher confirms RabbitMQ extension.
    NrZooFSS�s�BlB�BsBBcCsi|]}|j|�qSr)�
method_sig��.0�mrrr�
<dictcomp>��zConnection.<dictcomp>zlocalhost:5672Zguestr�/�en_USFcst��j|_|pd}|
pd}
|r:t|tj�r2|f}||_n�|dur�|dkrVt�|�}n�|dkrht�	�}n||dkr�|dus�|dur�t
d��t�||�}nN|dkr�|dus�|dur�t
d��t�||�}n |dur�t�
||�}n
t
d|��|f|_n,tj|d	d
�t�	�t�||�t�||�f|_t|jfi|	�p,i��|_||_||_||_t|�|_||_||_d|_i|_t��|d�d|_d|_d|_||_|
|_ ||_!||_"|
|_#||_$||_%||_&||_'||_(t|�|_)t*d
�|_+d|_,d|_-i|_.g|_/g|_0||_1dS)Ni��i�GSSAPI�EXTERNAL�AMQPLAINz-Must supply authentication or userid/password�PLAINzInvalid login methodT)Z	fail_softFr�H)2�uuid�uuid4�hex�_connection_id�
isinstancerZSASL�authenticationr+r,�
ValueErrorr-r.ZRAW�dict�library_properties�client_properties�locale�host�virtual_hostr�
on_tune_ok�frame_handler_cls�frame_writer_cls�_handshake_complete�channels�super�__init__�
_frame_writer�_on_inbound_frame�
_transport�channel_max�	frame_max�client_heartbeat�confirm_publish�ssl�read_timeout�
write_timeout�socket_settings�
on_blocked�on_unblocked�on_openr�_used_channel_ids�
version_major�
version_minor�server_properties�
mechanisms�locales�connect_timeout)�selfr;Zuserid�passwordZlogin_method�login_responser5r<r:r9rKrXrGrH�	heartbeatrQrOrPrJr=rLrMrNrr�kwargs�auth��	__class__rrrC�s�

��



���


zConnection.__init__c	CsV|jr0d|j�d|j�d|j�dt|�d�d�	Sd|j�d|j�dt|�d�d�SdS)Nz<AMQP Connection: r)z using z at z#x�>z (disconnected) at )rFr;r<�id�rYrrr�__repr__s���zConnection.__repr__cCs|��|S�N)�connectrcrrr�	__enter__"szConnection.__enter__cGs|��dSre)�close)rYZeargsrrr�__exit__&szConnection.__exit__cCs|j�||�Sre)rQ�then)rYZ
on_successZon_errorrrrrj)szConnection.thencCs`|j�tjj|jtjj|jtjj|j	tjj
|jtjj|j
tjj|jtjj|jtjj|ji�dSre)�
_callbacks�updaterr�Start�	_on_start�OpenOk�_on_open_ok�Secure�
_on_secure�Tune�_on_tune�Close�	_on_close�Blocked�_on_blocked�	Unblocked�
_on_unblocked�CloseOk�_on_close_okrcrrr�_setup_listeners,s







�zConnection._setup_listenersc	Cs�|jr|r|�SdSzh|j|j|j|j|j|j|jd�|_|j�	�|�
||j�|_|�
||j�|_|jsz|j|jd�qdWn ttfy�|���Yn0dS)N)rN)�timeout)�	connectedrr;rXrKrLrMrN�	transportrfr>�on_inbound_method�on_inbound_framer?rr@�drain_events�OSErrorr�collect)rY�callbackrrrrf8s$�
�zConnection.connectcCst�ttj|d���dS)N)�attr)�warnings�warnr�W_FORCE_CONNECT�format)rYr�rrr�_warn_force_connectPs
�zConnection._warn_force_connectcCs"|jdur|�d�|��|jS)Nr�)rFr�rfrcrrrr�Ts

zConnection.transportcCs
||_dSre)rF)rYr�rrrr�[scCs"|jdur|�d�|��|jS)Nr�)rEr�rfrcrrrr�_s

zConnection.on_inbound_framecCs
||_dSre)rE)rYr�rrrr�fscCs"|jdur|�d�|��|jS)Nr)rDr�rfrcrrrrjs

zConnection.frame_writercCs
||_dSre)rD)rYrrrrrqs�FsSscs.|j}||_||_||_t|t�r,|�d�}|�d�|_|�d�|_	t
�t|j|j|j|j|j	�|�
d�pni�|�di�}|��fdd�|j��D��|s�|�dd�|jD](}	|	j|jvr�|	�|�}
|
tur��qq�td�d�d	d
�|jD����d�|j������|�tjj|||	j|
|jf�dS)Nzutf-8� � �capabilitiescs i|]\}}��|�r||�qSr)�get)r%Z
wanted_capZ
enable_cap�Zscaprrr'�s
�z(Connection._on_start.<locals>.<dictcomp>zGCouldn't find appropriate auth mechanism (can offer: {}; available: {})s, css|]}|jr|jVqdSre)�	mechanismr$rrr�	<genexpr>�s�z'Connection._on_start.<locals>.<genexpr>) r9rSrTrUr4�str�encode�splitrVrW�AMQP_LOGGER�debug�START_DEBUG_FMTr��
setdefaultrl�negotiate_capabilities�items�popr5r��start�NotImplementedr
r��join�decode�send_methodrrZStartOkr:)rYrSrTrUrVrW�argsigr9�capr5r[rr�rrnusN

��


�
����zConnection._on_startcCsdSrer)rY�	challengerrrrr�szConnection._on_securecCs�|jpd}|p|j|_|p|j|_|p(d|_|jdks>|dkrNt|j|�|_nt|j|�|_|jshd|_|jtj	j
||j|j|jf|jd�dS)Nr�r�)rIrGrH�server_heartbeat�maxr\�minr�rrZTuneOk�
_on_tune_sent)rYrGrHr�r�rIrrrrt�s

�zConnection._on_tune�ssbcCs|�tjj||jddf�dS)N�F)r�rr�Openr<)rYr�rrrr��s�zConnection._on_tune_sentcCsd|_|�|�dS)NT)r@rQrcrrrrp�szConnection._on_open_okcKst|f|||||d�|��S)N)rXrKrLrMrNr)rYr;rXrKrLrMrNr]rrrr�s���zConnection.TransportcCs|jo|jjSre)rFrrcrrrr�szConnection.connectedcsV�jr�j���jr@�fdd��j��D�}|D]}|��q2d�_�_�_dS)Ncsg|]}|�ur|�qSrr)r%�chrcrr�
<listcomp>�s�z&Connection.collect.<locals>.<listcomp>)rFrhrA�valuesr��
connection)rYrAr�rrcrr��s

�
zConnection.collectcCs^t|j�}td|jd�D] }||vr|j�|�|Sqtd�t|j�|j�t	j
j��dS)Nrz/No free channel ids, current={}, channel_max={})�setrR�rangerG�appendrr��lenrArr
r�)rYZused_channel_ids�
channel_idrrr�_get_free_channel_id�s

��zConnection._get_free_channel_idcCs0||jvrtd|�d���n|j�|�|SdS)NzChannel z
 already open)rRr
r�)rYr�rrr�_claim_channel_id�s
zConnection._claim_channel_idcCsR|jdurtd��z|j|WStyL|j|||d�}|��|YS0dS)z�Create new channel.

        Fetch a Channel object identified by the numeric channel_id, or
        create that object if it doesn't already exist.
        NzConnection already closed.)rQ)rAr�KeyErrorr
�open)rYr�r��channelrrrr��s
zConnection.channelcCstd��dS)NzUse AMQP heartbeats)�NotImplementedErrorrcrrr�is_alive	szConnection.is_alivecCs|�|�sqdSre)�
blocking_read)rYr~rrrr�s
zConnection.drain_eventscCs@|j�|��|j��}Wd�n1s,0Y|�|�Sre)r�Zhaving_timeoutZ
read_framer�)rYr~�framerrrr�s(zConnection.blocking_readcCs&|jdurtd��|j|�|||�S)NzConnection already closed)rArZdispatch_method)rYr�r#�payload�contentrrrr�s


�zConnection.on_inbound_methodr��rrc	Cs�|jdurdSzfz:d|_|jtjj||||d|dftjjd�WWd|_Sttfyj|�	��Yn0Wd|_nd|_0dS)�Request a connection close.

        This method indicates that the sender wants to close the
        connection. This may be due to internal conditions (e.g. a
        forced shut-down) or due to an error handling a specific
        method, i.e. an exception.  When a close is due to an
        exception, the sender provides the class and method id of the
        method which caused the exception.

        RULE:

            After sending this method any received method except the
            Close-OK method MUST be discarded.

        RULE:

            The peer sending this method MAY use a counter or timeout
            to detect failure of the other peer to respond correctly
            with the Close-OK method.

        RULE:

            When a server receives the Close method from a client it
            MUST delete all server-side resources associated with the
            client's context.  A client CANNOT reconnect to a context
            after sending or receiving a Close method.

        PARAMETERS:
            reply_code: short

                The reply code. The AMQ reply codes are defined in AMQ
                RFC 011.

            reply_text: shortstr

                The localised reply text.  This text can be logged as an
                aid to resolving issues.

            class_id: short

                failing method class

                When the close is provoked by a method exception, this
                is the class of the method.

            method_id: short

                failing method ID

                When the close is provoked by a method exception, this
                is the ID of the method.
        NTrr)�waitF)
rF�
is_closingr�rrrur{r�rr�)rY�
reply_code�
reply_textr#r�rrrrhs6
�
�
zConnection.closecCs|��t||||ft��dS)r�N)�_x_close_okrr
)rYr�r�Zclass_idZ	method_idrrrrvfs5�zConnection._on_closecCs|jtjj|jd�dS)ahConfirm a connection close.

        This method confirms a Connection.Close method and tells the
        recipient that it is safe to release resources for the
        connection and close the socket.

        RULE:
            A peer that detects a socket closure without having
            received a Close-Ok handshake method SHOULD log the error.
        r�N)r�rrr{r|rcrrrr��szConnection._x_close_okcCs|��dS)aiConfirm a connection close.

        This method confirms a Connection.Close method and tells the
        recipient that it is safe to release resources for the
        connection and close the socket.

        RULE:

            A peer that detects a socket closure without having
            received a Close-Ok handshake method SHOULD log the error.
        N)r�rcrrrr|�szConnection._on_close_okcCsd}|jr|�|�SdS)zlCallback called when connection blocked.

        Notes:
            This is an RabbitMQ Extension.
        z#connection blocked, see broker logsN)rO)rY�reasonrrrrx�szConnection._on_blockedcCs|jr|��SdSre)rPrcrrrrz�szConnection._on_unblockedcCs|�ddddd�dS)N�r)rrcrrr�send_heartbeat�szConnection.send_heartbeat�cCs
t�d|j�|jsdS|dkr$d}|j}|j}|jdusD|j|krLt�|_|j	dus`|j	|krht�|_
t�}t�d|j|j	||||j|j|j�	|||_|_	||j|j|kr�t�d|j�|��t�|_d|j}|j
|}|t�k}|j
�r|�rtd��dS)a�Send heartbeat packets if necessary.

        Raises:
            ~amqp.exceptions.ConnectionForvced: if none have been
                received recently.

        Note:
            This should be called frequently, on the order of
            once per second.

        Keyword Arguments:
            rate (int): Number of heartbeat frames to send during the heartbeat
                        timeout
        z"heartbeat_tick : for connection %sNrr�z�heartbeat_tick : Prev sent/recv: %s/%s, now - %s/%s, monotonic - %s, last_heartbeat_sent - %s, heartbeat int. - %s for connection %sz3heartbeat_tick: sending heartbeat for connection %szToo many heartbeats missed)
�AMQP_HEARTBEAT_LOGGERr�r3r\�
bytes_sent�
bytes_recv�	prev_sentr�last_heartbeat_sent�	prev_recv�last_heartbeat_receivedr�r)rYZrateZsent_nowZrecv_now�nowZtwo_heartbeatsZtwo_heartbeats_intervalZheartbeats_missedrrr�heartbeat_tick�sF���


zConnection.heartbeat_tickcCs|jjSre)r��sockrcrrrr�
szConnection.sockcCs|j�d�piS)Nr�)rUr�rcrrr�server_capabilitiesszConnection.server_capabilities)N)N)r�)r!)r�)FNNN)NN)N)N)rr�r�r")r�)Trrr�__doc__r
�NEGOTIATE_CAPABILITIESr��LIBRARY_PROPERTIESr8r\rIr�r�r�r�r�r�r�r�methodrrmrorqrsrurwryr{Z_METHODSZ_ALLOWED_METHODS_WHEN_CLOSINGr
�socket�error�IOErrorr�Zconnection_errorsrZchannel_errorsrrZrecoverable_connection_errorsrZrecoverable_channel_errorsrrrCrdrgrirjr}rfr��propertyr��setterr�rnrrrtr�rprrr�r�r�r�r�r�r�r�rhrvr�r|rxrzr�r�r�r��
__classcell__rrr_rr?s�.�
�����[







�
1

�





�
H9


?
r)/r��loggingr�r0r�r�timerZvinerr�rrrZabstract_channelr	r�r
�
exceptionsrrr
rrrrrrZmethod_framingrrr�rrKr�ImportError�	Exceptionr��stripr��__all__�	getLoggerr�r�r�r�rrrrr�<module>s@,	
���