File: //usr/local/lib/python3.9/site-packages/amqp/__pycache__/connection.cpython-39.pyc
a
X>h�k � @ s> d Z ddlZddlZddlZddlZddlmZ ddlmZ ddlm Z ddl
mZmZm
Z
ddlmZ dd lmZ dd
lmZmZmZmZmZmZmZmZmZ ddlmZmZ ddlm Z zdd
l!m"Z" W n" e#y� G dd� de$�Z"Y n0 dZ%d�&� Z'dZ(e�)d�Z*e�)d�Z+ded�Z,dddd�Z-G dd� 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 e Zd ZdS )r N)�__name__�
__module__�__qualname__� r r �9/usr/local/lib/python3.9/site-packages/amqp/connection.pyr s r z�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_closec s� e Zd ZdZeZeZeZdZ dZ
dZdZdZ
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
dddddd
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 )kr a� 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.
Nr ZooFSS�s�BlB�BsBBc C s i | ]}|j |�qS r )�
method_sig��.0�mr r r �
<dictcomp>� � zConnection.<dictcomp>zlocalhost:5672Zguestr �/�en_USFc s t �� j| _|pd}|
pd}
|r:t|tj�r2|f}|| _n�|d ur�|dkrVt�|�}n�|dkrht� � }n||dkr�|d u s�|d u r�t
d��t�||�}nN|dkr�|d u s�|d u r�t
d��t�||�}n |d ur�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|| _1d S )Ni�� i �GSSAPI�EXTERNAL�AMQPLAINz-Must supply authentication or userid/password�PLAINzInvalid login methodT)Z fail_softFr �H)2�uuid�uuid4�hex�_connection_id�
isinstancer ZSASL�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�passwordZlogin_method�login_responser5 r<