
    Mf#                     ,   d dl Z d dlZd dlZej        r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 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 G d de          Z G d de          Z G d d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)RetryCallStatec                   \    e Zd ZdZej        dddefd            ZddZdd	Z	ddZ
ddZdS )
retry_basez)Abstract base class for retry strategies.retry_stater   returnc                     d S N selfr   s     M/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/tenacity/retry.py__call__zretry_base.__call__   s        other	retry_allc                 ,    |                     |           S r	   )__rand__r   r   s     r   __and__zretry_base.__and__    s    ~~d###r   c                 "    t          ||           S r	   )r   r   s     r   r   zretry_base.__rand__#       %%%r   	retry_anyc                 ,    |                     |           S r	   )__ror__r   s     r   __or__zretry_base.__or__&   s    }}T"""r   c                 "    t          ||           S r	   )r   r   s     r   r   zretry_base.__ror__)   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   r   r      s        33$4     $ $ $ $& & & &# # # #& & & & & &r   r   r   c                   "    e Zd ZdZdddefdZdS )_retry_neverz-Retry strategy that never rejects any result.r   r   r   c                     dS )NFr
   r   s     r   r   z_retry_never.__call__3   s    ur   Nr   r   r   r    r#   r   r
   r   r   r%   r%   0   s=        77$4       r   r%   c                   "    e Zd ZdZdddefdZdS )_retry_alwaysz.Retry strategy that always rejects any result.r   r   r   c                     dS )NTr
   r   s     r   r   z_retry_always.__call__=   s    tr   Nr'   r
   r   r   r)   r)   :   s=        88$4       r   r)   c                   N    e Zd ZdZdej        egef         ddfdZdddefdZ	dS )	retry_if_exceptionzARetry strategy that retries if an exception verifies a predicate.	predicater   Nc                     || _         d S r	   r-   r   r-   s     r   __init__zretry_if_exception.__init__G       "r   r   r   c                     |j         t          d          |j         j        r?|j                                         }|t          d          |                     |          S dS )N(__call__() called before outcome was set(outcome failed but the exception is NoneFoutcomeRuntimeErrorfailed	exceptionr-   r   r   r:   s      r   r   zretry_if_exception.__call__J   sh    &IJJJ% 	#+5577I "#MNNN>>),,,5r   )
r   r   r   r    typingCallableBaseExceptionr#   r1   r   r
   r   r   r,   r,   D   sm        KK#&/=/42G"H #T # # # #
$4 
 
 
 
 
 
 
r   r,   c                        e Zd ZdZefdej        ej        e         ej	        ej        e         df         f         ddf fdZ
 xZS )retry_if_exception_typez=Retries if an exception has been raised of one or more types.exception_types.r   Nc                 `    | _         t                                          fd           d S )Nc                 $    t          |           S r	   
isinstanceerA   s    r   <lambda>z2retry_if_exception_type.__init__.<locals>.<lambda>b   s    :a#A#A r   rA   superr1   r   rA   	__class__s    `r   r1   z retry_if_exception_type.__init__Z   s6      /AAAABBBBBr   r   r   r   r    	Exceptionr<   UnionTyper>   Tupler1   __classcell__rL   s   @r   r@   r@   W   s        GG C CK&L]3S89;
C 
C C C C C C C C C Cr   r@   c                        e Zd ZdZefdej        ej        e         ej	        ej        e         df         f         ddf fdZ
 xZS )retry_if_not_exception_typezARetries except an exception has been raised of one or more types.rA   .r   Nc                 `    | _         t                                          fd           d S )Nc                 &    t          |            S r	   rD   rF   s    r   rH   z6retry_if_not_exception_type.__init__.<locals>.<lambda>p       z!_'E'E#E r   rI   rK   s    `r   r1   z$retry_if_not_exception_type.__init__h   6      /EEEEFFFFFr   rM   rS   s   @r   rU   rU   e   s        KK G GK&L]3S89;
G 
G G G G G G G G G Gr   rU   c                        e Zd ZdZefdej        ej        e         ej	        ej        e         df         f         ddf fdZ
dddefd	Z xZS )
retry_unless_exception_typez:Retries until an exception is raised of one or more types.rA   .r   Nc                 `    | _         t                                          fd           d S )Nc                 &    t          |            S r	   rD   rF   s    r   rH   z6retry_unless_exception_type.__init__.<locals>.<lambda>~   rX   r   rI   rK   s    `r   r1   z$retry_unless_exception_type.__init__v   rY   r   r   r   c                     |j         t          d          |j         j        sdS |j                                         }|t          d          |                     |          S Nr4   Tr5   r6   r;   s      r   r   z$retry_unless_exception_type.__call__   sj    &IJJJ ") 	4'1133	IJJJ~~i(((r   )r   r   r   r    rN   r<   rO   rP   r>   rQ   r1   r#   r   rR   rS   s   @r   r[   r[   s   s        DD G GK&L]3S89;
G 
G G G G G G)$4 ) ) ) ) ) ) ) ) )r   r[   c                       e Zd ZdZefdej        ej        e         ej	        ej        e         df         f         ddfdZ
dddefd	ZdS )
retry_if_exception_cause_typezRetries if any of the causes of the raised exception is of one or more types.

    The check on the type of the cause of the exception is done recursively (until finding
    an exception in the chain that has no `__cause__`)
    rA   .r   Nc                     || _         d S r	   )exception_cause_types)r   rA   s     r   r1   z&retry_if_exception_cause_type.__init__   s     &5"""r   r   r   c                     |j         t          d          |j         j        r@|j                                         }|%t	          |j        | j                  rdS |j        }|%dS )Nz&__call__ called before outcome was setTF)r7   r8   r9   r:   rE   	__cause__rc   )r   r   excs      r   r   z&retry_if_exception_cause_type.__call__   sr    &GHHH% 	$%//11C/cmT-GHH  4m /
 ur   )r   r   r   r    rN   r<   rO   rP   r>   rQ   r1   r#   r   r
   r   r   ra   ra      s          5 5K&L]3S89;
5 
5 5 5 5$4       r   ra   c                   X    e Zd ZdZdej        ej        gef         ddfdZdddefdZ	dS )	retry_if_resultz+Retries if the result verifies a predicate.r-   r   Nc                     || _         d S r	   r/   r0   s     r   r1   zretry_if_result.__init__   r2   r   r   r   c                     |j         t          d          |j         j        s,|                     |j                                                   S dS Nr4   Fr7   r8   r9   r-   resultr   s     r   r   zretry_if_result.__call__   sN    &IJJJ") 	>>+"5"<"<">">???5r   
r   r   r   r    r<   r=   Anyr#   r1   r   r
   r   r   rh   rh      so        55#&/6:,2D"E #$ # # # #$4       r   rh   c                   X    e Zd ZdZdej        ej        gef         ddfdZdddefdZ	dS )	retry_if_not_resultz*Retries if the result refutes a predicate.r-   r   Nc                     || _         d S r	   r/   r0   s     r   r1   zretry_if_not_result.__init__   r2   r   r   r   c                     |j         t          d          |j         j        s-|                     |j                                                    S dS rk   rl   r   s     r   r   zretry_if_not_result.__call__   sQ    &IJJJ") 	~~k&9&@&@&B&BCCCC5r   rn   r
   r   r   rq   rq      so        44#&/6:,2D"E #$ # # # #$4       r   rq   c                   b     e Zd ZdZ	 	 ddej        e         dej        e         ddf fdZ xZS )retry_if_exception_messagez2Retries if an exception message equals or matches.Nmessagematchr   c                 R   r|rt          | j        j         d          rdt          dt          ffd}|}nI|r+t          j        |          dt          dt          ffd}|}nt          | j        j         d          t                                          |           d S )Nz.() takes either 'message' or 'match', not bothr:   r   c                 *    t          |           k    S r	   )str)r:   rv   s    r   message_fncz8retry_if_exception_message.__init__.<locals>.message_fnc   s    #i..00r   c                 b    t                              t          |                               S r	   )r#   rw   rz   )r:   progs    r   	match_fncz6retry_if_exception_message.__init__.<locals>.match_fnc   s#    DJJs9~~66777r   z3() missing 1 required argument 'message' or 'match')		TypeErrorrL   r   r>   r#   recompilerJ   r1   )r   rv   rw   r{   r-   r~   r}   rL   s    `    @r   r1   z#retry_if_exception_message.__init__   s   
  	u 	>*ZZZ  
  	1} 1 1 1 1 1 1 1 $II 
	:e$$D8] 8t 8 8 8 8 8 8 "II>*___   	#####r   NN)	r   r   r   r    r<   Optionalrz   r1   rR   rS   s   @r   ru   ru      sz        << )-&*$ $%$ s#$ 
	$ $ $ $ $ $ $ $ $ $r   ru   c                   r     e Zd ZdZ	 	 d
dej        e         dej        e         ddf fdZdddefd	Z	 xZ
S )retry_if_not_exception_messagez5Retries until an exception message equals or matches.Nrv   rw   r   c                 p    t                                          ||           | j        fd| _        d S )Nc                       | i | S r	   r
   )args_kwargs_if_predicates     r   rH   z9retry_if_not_exception_message.__init__.<locals>.<lambda>   s    ||U7Vg7V7V3V r   )rJ   r1   r-   )r   rv   rw   r   rL   s      @r   r1   z'retry_if_not_exception_message.__init__   s;    
 	%(((~VVVVr   r   r   c                     |j         t          d          |j         j        sdS |j                                         }|t          d          |                     |          S r_   r6   r;   s      r   r   z'retry_if_not_exception_message.__call__   sh    &IJJJ") 	4'1133	IJJJ~~i(((r   r   )r   r   r   r    r<   r   rz   r1   r#   r   rR   rS   s   @r   r   r      s        ?? )-&*W W%W s#W 
	W W W W W W
)$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 )	r   z1Retries if any of the retries condition is valid.retriesr   Nc                     || _         d S r	   r   r   r   s     r   r1   zretry_any.__init__      r   r   r   c                 D    t          fd| j        D                       S )Nc              3   .   K   | ]} |          V  d S r	   r
   .0rr   s     r   	<genexpr>z%retry_any.__call__.<locals>.<genexpr>  +      88a11[>>888888r   )anyr   r   s    `r   r   zretry_any.__call__  (    88884<888888r   r   r   r   r    r   r1   r#   r   r
   r   r   r   r   	  s_        ;;     9$4 9 9 9 9 9 9 9r   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/Retries if all the retries condition are valid.r   r   Nc                     || _         d S r	   r   r   s     r   r1   zretry_all.__init__  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%retry_all.__call__.<locals>.<genexpr>  r   r   )allr   r   s    `r   r   zretry_all.__call__  r   r   r   r
   r   r   r   r     s_        99     9$4 9 9 9 9 9 9 9r   r   )r!   r   r<   TYPE_CHECKINGtenacityr   ABCr   rO   r=   r#   
RetryBaseTr%   retry_neverr)   retry_alwaysr,   r@   rU   r[   ra   rh   rq   ru   r   r   r   r
   r   r   <module>r      s  " 


 				 	 (''''''& & & & & & & &( \*fo7G6H$6N&OOP
    :    lnn    J    }       &C C C C C0 C C CG G G G G"4 G G G) ) ) ) )"4 ) ) )6    J   <    j        *     $  $  $  $  $!3  $  $  $F) ) ) ) )%? ) ) )49 9 9 9 9
 9 9 99 9 9 9 9
 9 9 9 9 9r   