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: //usr/local/lib/python3.10/dist-packages/tenacity/__pycache__/__init__.cpython-310.pyc
o

���g�]�@s`ddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZddl
mZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!m"Z"ddl!m#Z#ddl!m$Z$ddl!m%Z%ddl!m&Z&ddl!m'Z'ddl!m(Z(ddl)m*Z*ddl)m+Z+ddl)m,Z,dd l)m-Z-dd!l)m.Z.dd"l)m/Z/dd#l)m0Z0dd$l)m1Z1dd$l)m1Z2dd%l)m3Z3dd&l4m5Z5dd'l4m6Z6dd(l7m8Z8dd)l7m9Z9dd*l:m;Z;dd+l:m<Z<zddl=Z=Wne>�y,dZ=Ynwej?�rMddl@Z@dd,l
mAZBdd-lmCZCdd.l!mDZDdd/l)mEZEe�Fd0�ZGejFd1ejHd2ejIfd3�ZJiZKejLd4k�rneK�Md5d6i�ejNdlieK��Gd7d8�d8��ZOGd9d:�d:eP�ZQeR�ZSGd;d<�d<�ZTGd=d>�d>eU�ZVGd?d@�d@�ZWGdAdB�dBeW�ZXeR�ZYdCejZejIeRfdDejIdEejIfdFdG�Z[GdHdI�dIeP�Z\GdJdK�dK�Z]GdLdM�dMe	�Z^GdNdO�dOe^�Z_ejLdPk�r�ej`ejIZanej`ZaGdQdR�dRea�Z`GdSdT�dT�ZbejcdUeJdEeJfdVdW��Zejcee'e/�e�e6e9ddXe\df
dYejHejZedeUfgejZdejedffdZd[d\d]dWd^d_ejHdTgejZdejedffd`ejHdTgejZdejedffdaejfejHdTgejZdejedffdbegdcejhdIddejfejHdTgejZejIejeejIffdEejHeJgeJffdedW��ZdfejIdgejIdEejIfdhdW�ZddilimjZje=�r�ddjlkmlZlgdk�ZmdS)m�N)�ABC�abstractmethod)�futures�)�_utils)�
retry_base)�	retry_all)�retry_always)�	retry_any)�retry_if_exception)�retry_if_exception_type)�retry_if_exception_cause_type)�retry_if_not_exception_type)�retry_if_not_result)�retry_if_result)�retry_never)�retry_unless_exception_type)�retry_if_exception_message)�retry_if_not_exception_message��sleep)�sleep_using_event)�stop_after_attempt)�stop_after_delay)�stop_before_delay)�stop_all)�stop_any)�
stop_never)�stop_when_event_set)�
wait_chain)�wait_combine)�wait_exponential)�
wait_fixed)�wait_incrementing)�	wait_none)�wait_random)�wait_random_exponential)�wait_exponential_jitter)�
before_log)�before_nothing)�	after_log)�
after_nothing)�before_sleep_log)�before_sleep_nothing)�asyncio)�
RetryBaseT)�	StopBaseT)�	WaitBaseT�WrappedFnReturnT�	WrappedFn.)�bound)��
�slotsTc@speZdZUejed�Zejej	dgej
fed<dZe
ed<dZeed<dZe
ed<dZe
ed	<ddd
�ZdS)�	IterState)�default_factory�RetryCallState�actionsF�retry_run_resultr�delay_since_first_attempt�stop_run_result�is_explicit_retry�returnNcCs"g|_d|_d|_d|_d|_dS)NFr)r;r<r=r>r?��self�rC�</usr/local/lib/python3.10/dist-packages/tenacity/__init__.py�resetts

zIterState.reset�r@N)�__name__�
__module__�__qualname__�dataclasses�field�listr;�t�List�Callable�Any�__annotations__r<�boolr=�intr>r?rErCrCrCrDr8js
"�r8c@seZdZdZdS)�TryAgainz/Always retry the executed function when raised.N)rGrHrI�__doc__rCrCrCrDrT|srTc@�eZdZdS)�	DoAttemptN�rGrHrIrCrCrCrDrW��rWc@rV)�DoSleepNrXrCrCrCrDrZ�rYrZc@sReZdZUdZdZejeed<dZ	ej
eed<defdd�Zdefd	d
�ZdS)�
BaseActiona5Base class for representing actions to take by retry object.

    Concrete implementations must define:
    - __init__: to initialize all necessary fields
    - REPR_FIELDS: class variable specifying attributes to include in repr(self)
    - NAME: for identification in retry object methods and callbacks
    rC�REPR_FIELDSN�NAMEr@cs.d��fdd��jD��}�jj�d|�d�S)Nz, c3s$�|]
}|�dt�|���VqdS)�=N)�getattr)�.0rKrArCrD�	<genexpr>�s�
�z&BaseAction.__repr__.<locals>.<genexpr>�(�))�joinr\�	__class__rG)rB�	state_strrCrArD�__repr__�s�zBaseAction.__repr__cCst|�S�N)�reprrArCrCrD�__str__�szBaseAction.__str__)
rGrHrIrUr\rM�Sequence�strrQr]�OptionalrgrjrCrCrCrDr[�s
r[c@s(eZdZdZdZdejddfdd�ZdS)�RetryActionr�retryrr@NcCst|�|_dSrh)�floatr)rBrrCrCrD�__init__�szRetryAction.__init__)rGrHrIr\r]rM�
SupportsFloatrqrCrCrCrDrn�srn�first�secondr@cCs|tur|S|Srh)�_unset)rsrtrCrCrD�
_first_set�srvcs@eZdZdZd�fdd�Zdejfdd	�Zdefd
d�Z	�Z
S)
�
RetryErrorz>Encapsulates the last attempt instance right before giving up.�last_attempt�Futurer@Ncs||_t��|�dSrh)rx�superrq)rBrx�rerCrDrq�szRetryError.__init__cCs|jjr	|j���|�rh)rx�failed�resultrArCrCrD�reraise�s
zRetryError.reraisecCs|jj�d|j�d�S)N�[�])rerGrxrArCrCrDrj��zRetryError.__str__)rxryr@N)rGrHrIrUrqrM�NoReturnr~rlrj�
__classcell__rCrCr{rDrw�s
rwc	@s\eZdZdZddd�Zddd	�Zd
ejeje	deje	dejd
deje
fdd�ZdS)�AttemptManagerzManage attempt context.�retry_stater:cCs
||_dSrh�r��rBr�rCrCrDrq�s
zAttemptManager.__init__r@NcC�dSrhrCrArCrCrD�	__enter__��zAttemptManager.__enter__�exc_type�	exc_value�	tracebackztypes.TracebackTypecCs6|dur|dur|j�|||f�dS|j�d�dS)NT)r��
set_exception�
set_result)rBr�r�r�rCrCrD�__exit__�s
zAttemptManager.__exit__)r�r:rF)rGrHrIrUrqr�rMrm�Type�
BaseExceptionrRr�rCrCrCrDr��s

����r�c@s�eZdZeee�e�eedde	df
de
je
je
efgdfdddddd	d
e
jdgdfde
jdgdfd
e
je
jdgdfdede
je	de
je
jdge
jffdd�Zeeeeeeeeeef
de
je
je
je
efgdfefde
jdefde
jdefde
jeefd
e
je
jdgdfefde
je
jdgdfefd
e
je
je
jdgdfefde
jeefde
je
je	efde
je
je
jdge
jfefddfdd�Zdefdd�Zede
jee
jffdd��Zedefdd��Zdedefdd�Z d:dd �Z!d!e
jd"e
jfddfd#d$�Z"d;d&d'�Z#d;d(d)�Z$d;d*d+�Z%d%dde
je&e'e
jffd,d-�Z(d;d.d/�Z)d;d0d1�Z*d;d2d3�Z+de
j,e-ddffd4d5�Z.e/d!e
jd"e0fd6e
jd7e
jde0fd8d9��Z1dS)<�BaseRetryingNFr�stopr0�waitr1ror/�beforer:�after�before_sleepr~�retry_error_cls�retry_error_callbackcCsJ||_||_||_||_||_||_||_||_t�	�|_
|	|_|
|_dSrh)
rr�r�ror�r�r�r~�	threading�local�_localr�r��rBrr�r�ror�r�r�r~r�r�rCrCrDrq�s


zBaseRetrying.__init__r@c
Csn|jt||j�t||j�t||j�t||j�t||j�t||j�t||j�t||j	�t|	|j
�t|
|j�d�
S)z8Copy this object with some parameters changed if needed.�
rr�r�ror�r�r�r~r�r�)rervrr�r�ror�r�r�r~r�r�r�rCrCrD�copy�s








��zBaseRetrying.copycCsLd|jj�dt|�d�d|j�d|j�d|j�d|j�d|j�d	|j�d
�S)N�<z
 object at 0x�xz (stop=z, wait=z, sleep=z, retry=z	, before=z, after=z)>)	rerG�idr�r�rror�r�rArCrCrDrgs�������zBaseRetrying.__repr__cCsBz|jjWSty t�tjttjfi�|j_|jjYSw)aSReturn a dictionary of runtime statistics.

        This dictionary will be empty when the controller has never been
        ran. When it is running or has ran previously it should have (but
        may not) have useful and/or informational keys and values when
        running is underway and/or completed.

        .. warning:: The keys in this dictionary **should** be some what
                     stable (not changing), but there existence **may**
                     change between major releases as new statistics are
                     gathered or removed so before accessing keys ensure that
                     they actually exist and handle when they do not.

        .. note:: The values in this dictionary are local to the thread
                  running call (so if multiple threads share the same retrying
                  object - either directly or indirectly) they will each have
                  there own view of statistics they have collected (in the
                  future we may provide a way to aggregate the various
                  statistics from each thread).
        )r��
statistics�AttributeErrorrM�cast�DictrlrPrArCrCrDr�s
�zBaseRetrying.statisticscCs0z|jjWStyt�|j_|jjYSwrh)r��
iter_stater�r8rArCrCrDr�:s

�zBaseRetrying.iter_state�fcslt��tjd�dtjdtjdtjf���fdd���dtjdtjdtf��fdd	�}��_|�_i�_�S)
z[Wrap a function for retrying.

        :param f: A function to wraps for retrying.
        )�__defaults__�__kwdefaults__�args�kwr@cs&���}|j�_|�g|�Ri|��Srh)r�r�)r�r�r��r�rB�	wrapped_frCrDr�Hsz%BaseRetrying.wraps.<locals>.wrapped_f�kwargscs�j|i|�����Srh)r��wraps)r�r�)r�rBrCrD�
retry_withRr�z&BaseRetrying.wraps.<locals>.retry_with)	�	functoolsr��WRAPPER_ASSIGNMENTSrMrPr3ror�r�)rBr�r�rCr�rDr�Bs
�& zBaseRetrying.wrapscCs0|j��t��|jd<d|jd<d|jd<dS)N�
start_timer�attempt_numberr�idle_for)r��clear�time�	monotonicrArCrCrD�begin\s

zBaseRetrying.begin�fn.cCs|jj�|�dSrh)r�r;�append)rBr�rCrCrD�_add_action_funcb�zBaseRetrying._add_action_funcr�cCs|�|�|j_dSrh)ror�r<r�rCrCrD�
_run_retryer�zBaseRetrying._run_retrycCs |jr	|�|�}nd}||_dS)N�)r��upcoming_sleep)rBr�rrCrCrD�	_run_waiths
zBaseRetrying._run_waitcCs|j|jd<|�|�|j_dS)Nr=)�seconds_since_startr�r�r�r>r�rCrCrD�	_run_stoppszBaseRetrying._run_stopcCs(|�|�d}|jjD]}||�}q|Srh)�_begin_iterr�r;)rBr�r}�actionrCrCrD�iterts


zBaseRetrying.itercCs||j��|j}|dur |jdur|�|j�|�dd��dS|jo)t|��t�|j_	|jj	s6|�|j
�|�|j�dS)NcSst�Srh)rW��rsrCrCrD�<lambda>�sz*BaseRetrying._begin_iter.<locals>.<lambda>)r�rE�outcomer�r�r|�
isinstance�	exceptionrTr?r��_post_retry_check_actions)rBr��futrCrCrDr�{s

�zBaseRetrying._begin_itercCs`|jjs|jjs|�dd��dS|jdur|�|j�|�|j�|�|j�|�|j�dS)NcSs
|j��Srh)r�r}r�rCrCrDr���
z8BaseRetrying._post_retry_check_actions.<locals>.<lambda>)r�r?r<r�r�r�r��_post_stop_check_actionsr�rCrCrDr��s
z&BaseRetrying._post_retry_check_actionscsz�jjr�jr���j�dSd
�fdd�}��|�dSd
�fdd�}��|��jdur4���j���dd	��dS)Nr�r:r@cs0t�t|j�}��|�}�jr|���||���rh)rMr�ryr�r�r~r�)r�r��	retry_excrArCrD�	exc_check�s


z8BaseRetrying._post_stop_check_actions.<locals>.exc_checkcsF|j}t|�|_|j|7_�jd|7<�jdd7<dS)Nr�r�r)r�rn�next_actionr�r�)r�rrArCrDr��s

z:BaseRetrying._post_stop_check_actions.<locals>.next_actioncSs
t|j�Srh)rZr�r�rCrCrDr��r�z7BaseRetrying._post_stop_check_actions.<locals>.<lambda>)r�r:r@N)r�r>r�r�r�)rBr�r�r�rCrArDr��s


z%BaseRetrying._post_stop_check_actionsccsd�|��t|ddid�}	|j|d�}t|t�r t|d�Vnt|t�r/|��|�|�ndSq)NrC)r�r�r�Tr�)	r�r:r�r�rWr�rZ�prepare_for_next_attemptr)rBr��dorCrCrD�__iter__�s�

�zBaseRetrying.__iter__r�r�cOr�rhrC)rBr�r�r�rCrCrD�__call__�szBaseRetrying.__call__rF)r�r:r@N)2rGrHrIrrr$rr)r+rwrMrO�UnionrSrprmrRr�rPrqru�objectrr�rlrg�propertyr�r�r8r�r3r�r�r�r�r�r�rWrZr�r�r�r��	Generatorr�r�rr2r�rCrCrCrDr��s���������	�
�
��"����������
��
�!



 


����r�c@s8eZdZdZdejdefdejdejdefdd�Zd	S)
�RetryingzRetrying controller.r�.r�r�r@cOs�|��t||||d�}	|j|d�}t|t�r8z	||i|��}Wnty1|�t���Ynw|�	|�nt|t
�rG|��|�|�n|Sq
)N)�retry_objectr�r�r�Tr�)
r�r:r�r�rWr�r��sys�exc_infor�rZr�r)rBr�r�r�r�r�r}rCrCrDr��s 
�
�zRetrying.__call__N)	rGrHrIrUrMrOr2rPr�rCrCrCrDr��s����r�)r5�	c	s\eZdZdZdeddf�fdd�Zedefdd��Ze	ded	e
jd
eddfdd��Z�Z
S)
ryzDEncapsulates a (future or past) attempted call to a target function.r�r@Ncst���||_dSrh)rzrqr�)rBr�r{rCrDrq�s

zFuture.__init__cCs|��duS)z8Return whether a exception is being held in this future.N)r�rArCrCrDr|�sz
Future.failed�value�
has_exceptioncCs(||�}|r
|�|�|S|�|�|S)zConstruct a new Future object.)r�r�)�clsr�r�r�r�rCrCrD�	construct�s

�zFuture.construct)rGrHrIrUrSrqr�rRr|�classmethodrMrPr�r�rCrCr{rDry�s����ryc
@s�eZdZdZdedejedejdejddf
dd	�Z	e
dejefd
d��Zddd
�Z
dejddfdd�Zdejejeedfddfdd�Zdefdd�ZdS)r:z5State related to a single call wrapped with Retrying.r�r�r�r�r@NcCsJt��|_||_||_||_||_d|_d|_d|_	d|_
d|_d|_dS)Nrr�)
r�r�r�r�r�r�r�r�r��outcome_timestampr�r�r�)rBr�r�r�r�rCrCrDrqs

zRetryCallState.__init__cCs|jdurdS|j|jSrh)r�r�rArCrCrDr�+s
z"RetryCallState.seconds_since_startcCs$d|_d|_|jd7_d|_dS�Nr)r�r�r�r�rArCrCrDr�1s
z'RetryCallState.prepare_for_next_attempt�valcCs.t��}t|j�}|�|�|||_|_dSrh)r�r�ryr�r�r�r�)rBr��tsr�rCrCrDr�7s

zRetryCallState.set_resultr�ztypes.TracebackType| NonecCs2t��}t|j�}|�|d�|||_|_dSr�)r�r�ryr�r�r�r�)rBr�r�r�rCrCrDr�=s
zRetryCallState.set_exceptioncCs�|jdurd}n|jjr|j��}d|jj�d|�d�}nd|j����}tt|jd��}|jj}d|�dt	|��d|j
�d	|�d
|�d�S)Nznone yetzfailed (� rcz	returned �r�z: attempt #z; slept for z; last result: �>)r�r|r�rerGr}rp�roundr�r�r�)rBr}r��slept�clsnamerCrCrDrgHs

*zRetryCallState.__repr__rF)rGrHrIrUr�rMrmr3rPrqr�rpr�r�r��Tupler�r�r�rlrgrCrCrCrDr:	s2����
�
��
�r:�funccCr�rhrC)r�rCrCrDroVr�roFrr�r0r�r1z.t.Union[RetryBaseT, tasyncio.retry.RetryBaseT]r�r�r�r~r�r�c

Cr�rhrCr�rCrCrDroZs�dargs�dkwcsBt��dkrt�d�rt��d�Sdtdtf��fdd�}|S)z�Wrap a function with a new `Retrying` object.

    :param dargs: positional arguments passed to Retrying object
    :param dkw: keyword arguments passed to the Retrying object
    rrr�r@cs�t|t�rt�d|jj�d|jj�d��t�|�r"t�i���}nt	r8t
t	jd�r8t	j�|�r8t
�i���}nt�i���}|�|�S)NzGot retry_base instance (zQ) as callable argument, this will probably hang indefinitely (did you mean retry=z(...)?)�is_coroutine_function)r�r�warnings�warnrerGr�is_coroutine_callable�
AsyncRetrying�tornado�hasattr�genr��TornadoRetryingr�r�)r��r�r�r�rCrD�wrap|s"
��
�
�
�
zretry.<locals>.wrap)�len�callableror3)r�r�rrCrrDroqs)r�)r�)6rrr	r
rrr
rrrrrrrrrrrrrrrrrr r!r"r#r$r%r&�wait_full_jitterr'r(r)r*r+r,r-ror3rT�	NO_RESULTrWrZr[rnrwr�r�r�ryr:r�rC)nrJr�r�r�r��typingrMr��abcrr�
concurrentr�rrorrr	r
rrr
rrrrrrr�naprrr�rrrrrrrr�rr r!r"r#r$r%r&rr'r�r(r)r�r*r+r�r,r-r��ImportError�
TYPE_CHECKING�typesr.�tasyncior/r0r1�TypeVarr2rOrPr3�dataclass_kwargs�version_info�update�	dataclassr8�	ExceptionrTr�rrWrprZr[rnrur�rvrwr�r�r�ry�FutureGenericTr:�overloadrS�	AwaitablermrRr��tenacity.asyncior��tenacity.tornadowebr��__all__rCrCrCrD�<module>s�
&wM�(������������"���"