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

���gq�@sddlZddlZddlZddlmZejrddlmZGdd�dej�Zej	eej
dgej	eefffZ
Gdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�N)�_utils)�RetryCallStatec@sJeZdZdZejdddefdd��Zdd	d
�Zddde	j
dfdd
�ZdS)�	wait_basez(Abstract base class for wait strategies.�retry_stater�returncCsdS�N���selfrrr�8/usr/local/lib/python3.10/dist-packages/tenacity/wait.py�__call__szwait_base.__call__�other�wait_combinecCs
t||�Sr)r�r
r
rrr�__add__"�
zwait_base.__add__)rrcCs|dkr|S|�|�S�Nr)rrrrr�__radd__%s
zwait_base.__radd__N)r
rrr)�__name__�
__module__�__qualname__�__doc__�abc�abstractmethod�floatrr�typing�Unionrrrrrrs
rrc@s6eZdZdZdejddfdd�Zdddefd	d
�ZdS)�
wait_fixedzCWait strategy that waits a fixed amount of time between each retry.�waitrNcCst�|�|_dSr)r�
to_secondsr)r
rrrr�__init__4�zwait_fixed.__init__rrcCs|jSr)rr	rrrr7szwait_fixed.__call__�	rrrrr�time_unit_typer rrrrrrr1srcs"eZdZdZd�fdd�Z�ZS)�	wait_nonez7Wait strategy that doesn't wait at all before retrying.rNcst��d�dSr)�superr )r
��	__class__rrr >r!zwait_none.__init__)rN)rrrrr �
__classcell__rrr&rr$;sr$c@s@eZdZdZ	ddejdejddfdd	�Zd
ddefdd
�ZdS)�wait_randomzAWait strategy that waits a random amount of time between min/max.r��min�maxrNcCst�|�|_t�|�|_dSr)rr�wait_random_min�wait_random_max)r
r+r,rrrr Eszwait_random.__init__rrcCs|jt��|j|jSr)r-�randomr.r	rrrrKs�zwait_random.__call__)rr*r"rrrrr)Bs���
�r)c@�4eZdZdZdeddfdd�Zdddefd	d
�ZdS)rz#Combine several waiting strategies.�
strategiesrNcG�
||_dSr)�
wait_funcs�r
r1rrrr Trzwait_combine.__init__rrcst�fdd�|jD��S)Nc3s�|]}|�d�VqdS)�rNr)�.0�xr5rr�	<genexpr>Xs�z(wait_combine.__call__.<locals>.<genexpr>)�sumr3r	rr5rrWszwait_combine.__call__�rrrrrr rrrrrrrQsrc@r0)�
wait_chaina�Chain two or more waiting strategies.

    If all strategies are exhausted, the very last strategy is used
    thereafter.

    For example::

        @retry(wait=wait_chain(*[wait_fixed(1) for i in range(3)] +
                               [wait_fixed(2) for j in range(5)] +
                               [wait_fixed(5) for k in range(4)))
        def wait_chained():
            print("Wait 1s for 3 attempts, 2s for 5 attempts and 5s
                   thereafter.")
    r1rNcGr2r)r1r4rrrr krzwait_chain.__init__rrcCs0tt|jd�t|j��}|j|d}||d�S)Nr*r5)r+r,�attempt_number�lenr1)r
r�wait_func_no�	wait_funcrrrrns
zwait_chain.__call__r:rrrrr;[sr;c	@sLeZdZdZddejfdejdejdejddfd	d
�Zdddefd
d�Z	dS)�wait_incrementingz�Wait an incremental amount of time after each attempt.

    Starting at a starting value and incrementing by a value for each attempt
    (and restricting the upper limit to some maximum value).
    r�d�start�	incrementr,rNcCs(t�|�|_t�|�|_t�|�|_dSr)rrrBrCr,)r
rBrCr,rrrr {szwait_incrementing.__init__rrcCs(|j|j|jd}tdt||j��S�Nr*r)rBrCr<r,r+)r
r�resultrrrr�szwait_incrementing.__call__)
rrrrr�MAX_WAITr#r rrrrrrr@ts����
�
r@c@sdeZdZdZdejddfdejee	fdej
dejee	fdej
d	d
f
dd�Zd
dd	e	fdd�Zd
S)�wait_exponentialaWait strategy that applies exponential backoff.

    It allows for a customized multiplier and an ability to restrict the
    upper and lower limits to some maximum and minimum value.

    The intervals are fixed (i.e. there is no jitter), so this strategy is
    suitable for balancing retries against latency when a required resource is
    unavailable for an unknown duration, but *not* suitable for resolving
    contention between multiple processes for a shared resource. Use
    wait_random_exponential for the latter case.
    r*�r�
multiplierr,�exp_baser+rNcCs(||_t�|�|_t�|�|_||_dSr)rIrrr+r,rJ)r
rIr,rJr+rrrr �s
zwait_exponential.__init__rrcCsRz|j|jd}|j|}Wnty|jYSwttd|j�t||j��SrD)rJr<rI�
OverflowErrorr,r+)r
r�exprErrrr�s
�zwait_exponential.__call__)
rrrrrrFrr�intrr#r rrrrrrG�s$�����
�rGcs*eZdZdZdddef�fdd�Z�ZS)�wait_random_exponentialaRandom wait with exponentially widening window.

    An exponential backoff strategy used to mediate contention between multiple
    uncoordinated processes for a shared resource in distributed systems. This
    is the sense in which "exponential backoff" is meant in e.g. Ethernet
    networking, and corresponds to the "Full Jitter" algorithm described in
    this blog post:

    https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/

    Each retry occurs at a random time in a geometrically expanding interval.
    It allows for a custom multiplier and an ability to restrict the upper
    limit of the random interval to some maximum value.

    Example::

        wait_random_exponential(multiplier=0.5,  # initial window 0.5s
                                max=60)          # max 60s timeout

    When waiting for an unavailable resource to become available again, as
    opposed to trying to resolve contention for a shared resource, the
    wait_exponential strategy (which uses a fixed interval) may be preferable.

    rrrcst�j|d�}t�|j|�S)Nr5)r%rr/�uniformr+)r
r�highr&rrr�sz wait_random_exponential.__call__)rrrrrrr(rrr&rrN�srNc@sLeZdZdZdejddfdededededd	f
d
d�Zdd
defdd�Zd	S)�wait_exponential_jittera`Wait strategy that applies exponential backoff and jitter.

    It allows for a customized initial wait, maximum wait and jitter.

    This implements the strategy described here:
    https://cloud.google.com/storage/docs/retry-strategy

    The wait time is min(initial * 2**n + random.uniform(0, jitter), maximum)
    where n is the retry count.
    r*rH�initialr,rJ�jitterrNcCs||_||_||_||_dSr)rRr,rJrS)r
rRr,rJrSrrrr �s
z wait_exponential_jitter.__init__rrcCs\t�d|j�}z|j|jd}|j||}Wnty$|j}Ynwtdt||j��S)Nrr*)	r/rOrSrJr<rRrKr,r+)r
rrSrLrErrrr�s
�z wait_exponential_jitter.__call__)	rrrrrrFrr rrrrrrQ�s$
�����
�rQ)rr/r�tenacityr�
TYPE_CHECKINGr�ABCrr�CallablerrM�	WaitBaseTrr$r)rr;r@rGrNrQrrrr�<module>s&�

"