Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/celery/backends/__pycache__/cosmosdbsql.cpython-39.pyc
Ðазад
a t�hy � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m Z ddlmZ zDdd l Z dd lmZ ddlmZmZmZ ddlmZ dd lmZ W n. ey� d Z Z Z Z Z ZZY n0 dZdZdZe e�ZG dd� de�Zd S )z3The CosmosDB/SQL backend for Celery (experimental).� )�cached_property)�bytes_to_str)� _parse_url)�ImproperlyConfigured)� get_logger� )�KeyValueStoreBackendN)�DocumentClient)�ConnectionPolicy�ConsistencyLevel� PartitionKind)�HTTPFailure)�RetryOptions)�CosmosDBSQLBackendi� i� c s� e Zd ZdZd� fdd� Zedd� �Zedd� �Zd d � Z dd� Z ed d� �Zedd� �Zdd� Z edd� �Zdd� Zdd� Zdd� Zdd� Z� ZS )r z CosmosDB/SQL backend for Celery.Nc s� t � j|i |�� td u r"td��| jj} | �|�\| _| _|pF| d | _ |pT| d | _ ztt|ph| d �| _ W n ty� td��Y n0 |p�| d | _|p�| d | _d S )NzIYou need to install the pydocumentdb library to use the CosmosDB backend.Zcosmosdbsql_database_nameZcosmosdbsql_collection_nameZcosmosdbsql_consistency_levelz"Unknown CosmosDB consistency levelZcosmosdbsql_max_retry_attemptsZcosmosdbsql_max_retry_wait_time)�super�__init__�pydocumentdbr Zapp�confr � _endpoint�_key�_database_name�_collection_name�getattrr �_consistency_level�AttributeError�_max_retry_attempts�_max_retry_wait_time) �self�urlZ database_nameZcollection_name�consistency_levelZmax_retry_attemptsZmax_retry_wait_time�args�kwargsr �� __class__� ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/celery/backends/cosmosdbsql.pyr ! s6 ���� ��zCosmosDBSQLBackend.__init__c C sZ t |�\}}}}}}}|r|s&td��|s.d}|dkr:dnd}|� d|� d|� �}||fS )NzInvalid URLi� �https�httpz://�:)r r )�clsr �_�host�port�password�schemeZendpointr$ r$ r% r M s zCosmosDBSQLBackend._parse_urlc C sJ t � }t| j| jd�|_t| jd| ji|| jd�}| �|� | � |� |S )z�Return the CosmosDB/SQL client. If this is the first call to the property, the client is created and the database and collection are initialized if they don't yet exist. )Zmax_retry_attempt_countZmax_wait_time_in_secondsZ masterKey)�connection_policyr ) r r r r r r r r �_create_database_if_not_exists� _create_collection_if_not_exists)r r/ �clientr$ r$ r% �_client[ s �� zCosmosDBSQLBackend._clientc C sX z|� d| ji� W n0 tyD } z|jtkr0� W Y d }~nd }~0 0 t�d| j� d S )N�idzCreated CosmosDB database %s)ZCreateDatabaser r �status_code�ERROR_EXISTS�LOGGER�info�r r2 �exr$ r$ r% r0 s s �z1CosmosDBSQLBackend._create_database_if_not_existsc C sl z$|� | j| jdgtjd�d�� W n0 tyT } z|jtkr@� W Y d }~nd }~0 0 t� d| j | j� d S )Nz/id)�paths�kind)r4 �partitionKeyz!Created CosmosDB collection %s/%s)ZCreateCollection�_database_linkr r ZHashr r5 r6 r7 r8 r r9 r$ r$ r% r1 } s ��� �z3CosmosDBSQLBackend._create_collection_if_not_existsc C s d| j S )Nzdbs/)r �r r$ r$ r% r>