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__/pools.cpython-310.pyc
o

'we��@sdZddlmZddlZddlmZddlmZddlm	Z	ddl
mZdd	lm
Z
dd
lmZdZdgZgZe�Zej�d
�Zdd�ZGdd�de�ZGdd�de�Zdd�ZGdd�de�Zeeed��ZGdd�de�Zeeed��Zdd�Z dd�Z!d$d d!�Z"d"d#�Z#dS)%zPublic resource pools.�)�annotationsN)�chain�)�Resource)�Producer)�EqualityDict)�register_after_fork)�lazy)�ProducerPool�	PoolGroup�register_group�connections�	producers�	get_limit�	set_limit�reset�
�KOMBU_DISABLE_LIMIT_PROTECTIONcCs|��dS�N)�clear��group�r�D/home/arjun/projects/env/lib/python3.10/site-packages/kombu/pools.py�_after_fork_cleanup_group�rcsdeZdZdZeZdZ�fdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Z�fdd�Z
�ZS)r
z*Pool of :class:`kombu.Producer` instances.Tcs0||_|�dd�p|j|_t�j|i|��dS)Nr)r
�popr�super�__init__)�selfr
�args�kwargs��	__class__rrr szProducerPool.__init__cCs|jjdd�S)NT)�block)r
�acquire�rrrr�_acquire_connection%sz ProducerPool._acquire_connectioncCs.|��}z|�|�WSty|���wr)r'r�
BaseException�release)r�connrrr�create_producer(s�zProducerPool.create_producercCs
t|j�Sr)r	r+r&rrr�new0s
zProducerPool.newcCs.|jrt|j�D]}|j�|���qdSdSr)�limit�range�	_resource�
put_nowaitr,)r�_rrr�setup3s
�zProducerPool.setupcCsdSrr�r�resourcerrr�close_resource8szProducerPool.close_resourcecCsNt|�r|�}|jdur%|��}z|�|�W|Sty$|���w|Sr)�callable�_channelr'�reviver(r))r�pr*rrr�prepare;s
��zProducerPool.preparecs&|jr|j��d|_t��|�dSr)�__connection__r)�channelrr3r"rrr)Gs
zProducerPool.release)�__name__�
__module__�__qualname__�__doc__r�close_after_forkrr'r+r,r2r5r:r)�
__classcell__rrr"rr
sr
c@s*eZdZdZd
dd�Zdd�Zdd	�ZdS)rzCollection of resource pools.NTcCs0||_||_|jrtdurt|t�dSdSdSr)r-rArr)rr-rArrrrQs
�zPoolGroup.__init__cCstd��)Nz!PoolGroups must define ``create``)�NotImplementedError)rr4r-rrr�createWszPoolGroup.createcCs,|j}|tur
t�}|�||�}||<|Sr)r-�use_global_limitrrD)rr4r-�krrr�__missing__Zs
zPoolGroup.__missing__)NT)r=r>r?r@rrDrGrrrrrNs

rcCst�|�|S)z*Register group (can be used as decorator).)�_groups�appendrrrrrbs
rc@�eZdZdZdd�ZdS)�ConnectionszCollection of connection pools.cCs|j|d�S�N�r-)�Pool�r�
connectionr-rrrrDkrzConnections.createN�r=r>r?r@rDrrrrrKh�rKrMc@rJ)�	ProducerszCollection of producer pools.cCstt||d�SrL)r
r
rOrrrrDuszProducers.createNrQrrrrrSrrRrScCstdd�tD��S)Ncss$�|]
}|r
|��ntg�VqdSr)�values�iter)�.0�grrr�	<genexpr>}s�"z_all_pools.<locals>.<genexpr>)rrHrrrr�
_all_pools|srYcCstdS)z"Get current connection pool limit.r)�_limitrrrrr�srFcCs>|pd}tdp	d}||kr|td<t�D]}|�|�q|S)zSet new connection pool limit.r)rZrY�resize)r-�force�reset_after�
ignore_errors�glimit�poolrrrr�s
rc	Os@t�D]}z|��WqtyYqwtD]}|��qdS)z*Reset all pools by closing open resources.N)rY�force_close_all�	ExceptionrHr)r r!r`rrrrr�s
�
�r)FFF)$r@�
__future__r�os�	itertoolsrrPr�	messagingr�utils.collectionsr�utils.compatr�utils.functionalr	�__all__rZrH�objectrE�environ�get�disable_limit_protectionrr
rrrKr
rSrrYrrrrrrr�<module>s44