
    Hcg#                        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y)     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y
)
retry_basez)Abstract base class for retry strategies.retry_stater   returnc                      y N selfr   s     I/var/www/html/bid-api/venv/lib/python3.12/site-packages/tenacity/retry.py__call__zretry_base.__call__   s        c                 $    |j                  |       S r	   )__rand__r   others     r   __and__zretry_base.__and__    s    ~~d##r   c                     t        ||       S r	   )	retry_allr   s     r   r   zretry_base.__rand__#       %%r   c                 $    |j                  |       S r	   )__ror__r   s     r   __or__zretry_base.__or__&   s    }}T""r   c                     t        ||       S r	   )	retry_anyr   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$4   $&#&r   r   r   c                        e Zd ZdZdddefdZy)_retry_neverz-Retry strategy that never rejects any result.r   r   r   c                      y)NFr
   r   s     r   r   z_retry_never.__call__3   s    r   Nr   r   r   r    r#   r   r
   r   r   r%   r%   0   s    7$4  r   r%   c                        e Zd ZdZdddefdZy)_retry_alwaysz.Retry strategy that always rejects any result.r   r   r   c                      y)NTr
   r   s     r   r   z_retry_always.__call__=   s    r   Nr'   r
   r   r   r)   r)   :   s    8$4  r   r)   c                   P    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	y)	retry_if_exceptionzARetry strategy that retries if an exception verifies a predicate.	predicater   Nc                     || _         y r	   r-   r   r-   s     r   __init__zretry_if_exception.__init__G   	    "r   r   r   c                     |j                   t        d      |j                   j                  r8|j                   j                         }|t        d      | j	                  |      S y)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   sa    &IJJ%%#++557I "#MNN>>),,r   )
r   r   r   r    typingCallableBaseExceptionr#   r1   r   r
   r   r   r,   r,   D   s<    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       y )Nc                     t        |       S r	   
isinstanceerA   s    r   <lambda>z2retry_if_exception_type.__init__.<locals>.<lambda>b   s    :a#Ar   rA   superr1   r   rA   	__class__s    `r   r1   z retry_if_exception_type.__init__Z   s      /ABr   r   r   r   r    	Exceptionr<   UnionTyper>   Tupler1   __classcell__rL   s   @r   r@   r@   W   s_    G CKK&LL]3S89;
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       y )Nc                     t        |        S r	   rD   rF   s    r   rH   z6retry_if_not_exception_type.__init__.<locals>.<lambda>p       z!_'E#Er   rI   rK   s    `r   r1   z$retry_if_not_exception_type.__init__h         /EFr   rM   rS   s   @r   rU   rU   e   s_    K GKK&LL]3S89;
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       y )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y|j                   j                         }|t        d      | j	                  |      S Nr4   Tr5   r6   r;   s      r   r   z$retry_unless_exception_type.__call__   sc    &IJJ ""))''113	IJJ~~i((r   )r   r   r   r    rN   r<   rO   rP   r>   rQ   r1   r#   r   rR   rS   s   @r   r[   r[   s   sm    D GKK&LL]3S89;
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y)
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                     || _         y 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                  rL|j                   j                         }|0t	        |j
                  | j                        ry|j
                  }|0y)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__   sn    &GHH%%%%//1C/cmmT-G-GHmm /
 r   )r   r   r   r    rN   r<   rO   rP   r>   rQ   r1   r#   r   r
   r   r   ra   ra      sk     5KK&LL]3S89;
5 
5$4  r   ra   c                   d    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	y)	retry_if_resultz+Retries if the result verifies a predicate.r-   r   Nc                     || _         y r	   r/   r0   s     r   r1   zretry_if_result.__init__   r2   r   r   r   c                     |j                   t        d      |j                   j                  s)| j                  |j                   j	                               S yNr4   Fr7   r8   r9   r-   resultr   s     r   r   zretry_if_result.__call__   sJ    &IJJ""))>>+"5"5"<"<">??r   
r   r   r   r    r<   r=   Anyr#   r1   r   r
   r   r   rh   rh      s@    5#&//6::,2D"E #$ #$4  r   rh   c                   d    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	y)	retry_if_not_resultz*Retries if the result refutes a predicate.r-   r   Nc                     || _         y r	   r/   r0   s     r   r1   zretry_if_not_result.__init__   r2   r   r   r   c                     |j                   t        d      |j                   j                  s*| j                  |j                   j	                                S yrk   rl   r   s     r   r   zretry_if_not_result.__call__   sM    &IJJ""))~~k&9&9&@&@&BCCCr   rn   r
   r   r   rq   rq      s@    4#&//6::,2D"E #$ #$4  r   rq   c                   j     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"t        | j                  j                   d      rdt        dt        ffd}|}nN|r*t        j                  |      dt        dt        ffd}|}n"t        | j                  j                   d      t        | !  |       y )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                 J    t        j                  t        |                   S r	   )r#   rw   rz   )r:   progs    r   	match_fncz6retry_if_exception_message.__init__.<locals>.match_fnc   s    DJJs9~6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>>**++YZ 
 1} 1 1 $I::e$D8] 8t 8 "I>>**++^_  	#r   NN)	r   r   r   r    r<   Optionalrz   r1   rR   rS   s   @r   ru   ru      sF    < )-&*$%$ s#$ 
	$ $r   ru   c                   z     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                 T    t         |   ||       | j                  fd| _        y )Nc                       | i | S r	   r
   )args_kwargs_if_predicates     r   rH   z9retry_if_not_exception_message.__init__.<locals>.<lambda>   s    |U7Vg7V3Vr   )rJ   r1   r-   )r   rv   rw   r   rL   s      @r   r1   z'retry_if_not_exception_message.__init__   s$    
 	%(~~Vr   r   r   c                     |j                   t        d      |j                   j                  sy|j                   j                         }|t        d      | j	                  |      S r_   r6   r;   s      r   r   z'retry_if_not_exception_message.__call__   sa    &IJJ""))''113	IJJ~~i((r   r   )r   r   r   r    r<   r   rz   r1   r#   r   rR   rS   s   @r   r   r      sY    ? )-&*W%W s#W 
	W
)$4 
) 
)r   r   c                   0    e Zd ZdZdeddfdZdddefdZy)	r   z1Retries if any of the retries condition is valid.retriesr   Nc                     || _         y r	   r   r   r   s     r   r1   zretry_any.__init__  	    r   r   r   c                 @    t        fd| j                  D              S )Nc              3   .   K   | ]  } |        y wr	   r
   .0rr   s     r   	<genexpr>z%retry_any.__call__.<locals>.<genexpr>       8<a1[><   )anyr   r   s    `r   r   zretry_any.__call__      84<<888r   r   r   r   r    r   r1   r#   r   r
   r   r   r   r   	  s,    ;  9$4 9 9r   r   c                   0    e Zd ZdZdeddfdZdddefdZy)	r   z/Retries if all the retries condition are valid.r   r   Nc                     || _         y r	   r   r   s     r   r1   zretry_all.__init__  r   r   r   r   c                 @    t        fd| j                  D              S )Nc              3   .   K   | ]  } |        y w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$4 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  "  	 	'& &( \\*foo7G6H$6N&OOP
:  nJ   &C0 CG"4 G)"4 )6J <j  *   $!3  $F)%? )49
 99
 9r   