
    Mf                     |   d dl Z d dlZd dlmZ ej        r
d dlZd dlmZ  G d de j                  Zej	        eej
        dgef         f         Z G d de          Z G d	 d
e          Z G d de          Z e            Z G d de          Z G d de          Z G d de          Z G d de          ZdS )    N)_utils)RetryCallStatec                   L    e Zd ZdZej        dddefd            ZddZdd
Z	dS )	stop_basez(Abstract base class for stop strategies.retry_stater   returnc                     d S N selfr   s     L/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/tenacity/stop.py__call__zstop_base.__call__   s        otherstop_allc                 "    t          | |          S r
   )r   r   r   s     r   __and__zstop_base.__and__"       e$$$r   stop_anyc                 "    t          | |          S r
   )r   r   s     r   __or__zstop_base.__or__%   r   r   N)r   r   r   r   )r   r   r   r   )
__name__
__module____qualname____doc__abcabstractmethodboolr   r   r   r   r   r   r   r      ss        22$4     % % % %% % % % % %r   r   r   c                   2    e Zd ZdZdeddfdZdddefdZdS )	r   z+Stop if any of the stop condition is valid.stopsr   Nc                     || _         d S r
   r"   r   r"   s     r   __init__zstop_any.__init__/       


r   r   r   c                 D    t          fd| j        D                       S )Nc              3   .   K   | ]} |          V  d S r
   r   .0xr   s     r   	<genexpr>z$stop_any.__call__.<locals>.<genexpr>3   +      66a11[>>666666r   )anyr"   r   s    `r   r   zstop_any.__call__2   (    66664:666666r   r   r   r   r   r   r&   r    r   r   r   r   r   r   ,   s_        55y T    7$4 7 7 7 7 7 7 7r   r   c                   2    e Zd ZdZdeddfdZdddefdZdS )	r   z*Stop if all the stop conditions are valid.r"   r   Nc                     || _         d S r
   r$   r%   s     r   r&   zstop_all.__init__9   r'   r   r   r   c                 D    t          fd| j        D                       S )Nc              3   .   K   | ]} |          V  d S r
   r   r*   s     r   r-   z$stop_all.__call__.<locals>.<genexpr>=   r.   r   )allr"   r   s    `r   r   zstop_all.__call__<   r0   r   r1   r   r   r   r   r   6   s_        44y T    7$4 7 7 7 7 7 7 7r   r   c                   "    e Zd ZdZdddefdZdS )_stop_neverzNever stop.r   r   r   c                     dS )NFr   r   s     r   r   z_stop_never.__call__C   s    ur   N)r   r   r   r   r    r   r   r   r   r8   r8   @   s=        $4       r   r8   c                   *    e Zd ZdZd
dZdddefd	ZdS )stop_when_event_setz!Stop when the given event is set.eventthreading.Eventr   Nc                     || _         d S r
   )r<   )r   r<   s     r   r&   zstop_when_event_set.__init__M   r'   r   r   r   c                 4    | j                                         S r
   )r<   is_setr   s     r   r   zstop_when_event_set.__call__P   s    z  """r   )r<   r=   r   N)r   r   r   r   r&   r    r   r   r   r   r;   r;   J   sQ        ++   #$4 # # # # # # #r   r;   c                   2    e Zd ZdZdeddfdZdddefdZdS )	stop_after_attemptz.Stop when the previous attempt >= max_attempt.max_attempt_numberr   Nc                     || _         d S r
   )rC   )r   rC   s     r   r&   zstop_after_attempt.__init__W   s    "4r   r   r   c                 "    |j         | j        k    S r
   )attempt_numberrC   r   s     r   r   zstop_after_attempt.__call__Z   s    )T-DDDr   )r   r   r   r   intr&   r    r   r   r   r   rB   rB   T   sg        8853 54 5 5 5 5E$4 E E E E E E Er   rB   c                   <    e Zd ZdZdej        ddfdZdddefdZdS )	stop_after_delayaS  
    Stop when the time from the first attempt >= limit.

    Note: `max_delay` will be exceeded, so when used with a `wait`, the actual total delay will be greater
    than `max_delay` by some of the final sleep period before `max_delay` is exceeded.

    If you need stricter timing with waits, consider `stop_before_delay` instead.
    	max_delayr   Nc                 8    t          j        |          | _        d S r
   r   
to_secondsrJ   r   rJ   s     r   r&   zstop_after_delay.__init__h       *955r   r   r   c                 N    |j         t          d          |j         | j        k    S Nz4__call__() called but seconds_since_start is not set)seconds_since_startRuntimeErrorrJ   r   s     r   r   zstop_after_delay.__call__k   s*    *2UVVV.$.@@r   	r   r   r   r   r   time_unit_typer&   r    r   r   r   r   rI   rI   ^   sn         6&"7 6D 6 6 6 6A$4 A A A A A A Ar   rI   c                   <    e Zd ZdZdej        ddfdZdddefdZdS )	stop_before_delaya  
    Stop right before the next attempt would take place after the time from the first attempt >= limit.

    Most useful when you are using with a `wait` function like wait_random_exponential, but need to make
    sure that the max_delay is not exceeded.
    rJ   r   Nc                 8    t          j        |          | _        d S r
   rL   rN   s     r   r&   zstop_before_delay.__init__y   rO   r   r   r   c                 ^    |j         t          d          |j         |j        z   | j        k    S rQ   )rR   rS   upcoming_sleeprJ   r   s     r   r   zstop_before_delay.__call__|   s7    *2UVVV+k.HH~	
r   rT   r   r   r   rW   rW   q   sf         6&"7 6D 6 6 6 6
$4 
 
 
 
 
 
 
r   rW   )r   typingtenacityr   TYPE_CHECKING	threadingr   ABCr   UnionCallabler    	StopBaseTr   r   r8   
stop_neverr;   rB   rI   rW   r   r   r   <module>rd      s    


       	 (''''''% % % % % % % % LFO5E4F4L$MMN	7 7 7 7 7y 7 7 77 7 7 7 7y 7 7 7    )    []]
# # # # #) # # #E E E E E E E EA A A A Ay A A A&
 
 
 
 
	 
 
 
 
 
r   