File: //usr/local/lib/python3.9/site-packages/kombu/__pycache__/connection.cpython-39.pyc
a
X>h � � @ s� d Z ddlmZ ddlZddlZddlZddlmZ ddlm Z m
Z
ddlmZ ddl
mZmZ zddlmZ d ZW n ey� dZd
ZY n0 ddlmZ dd
lmZ ddlmZ ddlmZmZ ddlmZ ddlm Z m!Z!m"Z"m#Z# ddl$m%Z% ddl&m'Z'm(Z(m)Z)m*Z*m+Z+ e�rTddl,m-Z- ej.dk �r<ddl/m0Z0 nddl
m0Z0 ddl1m2Z2 dZ3ee4�Z5e
Z6ddd�Z7e6e#d�Z8ej9�:dd
�Z;ej9�:dd
�Z<G dd� d�Z=e=Z>G d d!� d!e=�Z?G d"d#� d#e�Z@G d$d%� d%e�ZAd&d'd(�d)d*�ZBd+d,d-�d.d/�ZCdS )0zClient (Connection).� )�annotationsN)�contextmanager)�count�cycle)�
itemgetter)�
TYPE_CHECKING�Any)� CERT_NONETF)�
exceptions� )�
get_logger)�Resource)�get_transport_cls�supports_librabbitmq)� HashedSeq)�
dictfilter�lazy�retry_over_time�shufflecycle)�cached_property)�as_url�maybe_sanitize_url� parse_url�quote�urlparse)�Channel)� �
)� TypeGuard)�
TracebackType)�
Connection�ConnectionPool�ChannelPool�amqp)Zpyamqp�librabbitmq)�round-robin�shuffleZKOMBU_LOG_CONNECTIONZKOMBU_LOG_CHANNELc @ s� e Zd ZdZdZdZdZdZdZdZ dZ
dZdZdZ
dZdZdZdZeZeZd Z Z Z ZZd�d d
�Zdd� Zd
d� Zdd� Zdd� Zdd� Zdd� Zdd� Z d�dd�Z!dd� Z"dd� Z#d d!� Z$d"d#� Z%d$d%� Z&d�d&d'�Z'd(d)� Z(e(Z)d*d+� Z*d�d.d/�Z+e,e-j.e-j.fd0d1��Z/e,d2d3� �Z0d4d5� Z1d6d7� Z2d�d9d:�Z3d�d;d<�Z4d=d>� Z5d?d@� Z6dAdB� Z7dCdD� Z8d�dEdF�Z9dGdH� Z:dIdJ� Z;ddKe<dLdMdNdOdP�fdQdR�dSdT�Z=d�dUdV�Z>d�dWdX�Z?d�dYdZ�Z@d�d[d\�ZAd�d]d^�ZBd�d_d`�ZCdadb� ZDdcdd� ZEdedf� ZFdgdh� ZGdidj� ZHdkdl� ZIdmdndodpdq�drds�ZJeKdtdu� �ZLdvdw� ZMeKdxdy� �ZNeKdzd{� �ZOd|d}� ZPeKd~dR�dd���ZQeKd�d�� �ZReKd�d�� �ZSeTd�d�� �ZUd�d�� ZVeTd�d�� �ZWeTd�d�� �ZXeTd�d�� �ZYeTd�d�� �ZZeKd�d�� �Z[eKd�d�� �Z\dS )�r af
A connection to the broker.
Example:
-------
>>> Connection('amqp://guest:guest@localhost:5672//')
>>> Connection('amqp://foo;amqp://bar',
... failover_strategy='round-robin')
>>> Connection('redis://', transport_options={
... 'visibility_timeout': 3000,
... })
>>> import ssl
>>> Connection('amqp://', login_method='EXTERNAL', ssl={
... 'ca_certs': '/etc/pki/tls/certs/something.crt',
... 'keyfile': '/etc/something/system.key',
... 'certfile': '/etc/something/system.cert',
... 'cert_reqs': ssl.CERT_REQUIRED,
... })
Note:
----
SSL currently only works with the py-amqp, qpid and redis
transports. For other transports you can use stunnel.
Arguments:
---------
URL (str, Sequence): Broker URL, or a list of URLs.
Keyword Arguments:
-----------------
ssl (bool/dict): Use SSL to connect to the server.
Default is ``False``.
May not be supported by the specified transport.
transport (Transport): Default transport if not specified in the URL.
connect_timeout (float): Timeout in seconds for connecting to the
server. May not be supported by the specified transport.
transport_options (Dict): A dict of additional connection arguments to
pass to alternate kombu channel implementations. Consult the
transport documentation for available options.
heartbeat (float): Heartbeat interval in int/float seconds.
Note that if heartbeats are enabled then the
:meth:`heartbeat_check` method must be called regularly,
around once per second.
Note:
----
The connection is established lazily when needed. If you need the
connection to be established, then force it by calling
:meth:`connect`::
>>> conn = Connection('amqp://')
>>> conn.connect()
and always remember to close the connection::
>>> conn.release()
These options have been replaced by the URL argument, but are still
supported for backwards compatibility:
:keyword hostname: Host name/address.
NOTE: You cannot specify both the URL argument and use the hostname
keyword argument at the same time.
:keyword userid: Default user name if not provided in the URL.
:keyword password: Default password if not provided in the URL.
:keyword virtual_host: Default virtual host if not provided in the URL.
:keyword port: Default port if not provided in the URL.
N�/� Fr% � localhostr c K s� |d u rg n|}||||||||| ||
d� }| _ |r^t|t�s^|�|� |d }|j|d� |�rd|v r�|�d�| }|d }|j|d� d|v r�d|d |�d�� v r�|�dd�\|d<