
    Oǻi	                         d dl mZ d dlmZmZmZmZmZmZm	Z	m
Z
mZ d dlmZmZmZ d dlmZ  e
d      Zerd dlmZ  G d dee         Zy	)
    )sleep)	TYPE_CHECKINGAny	AwaitableCallableOptionalTupleTypeTypeVarUnion)ConnectionError
RedisErrorTimeoutError)AbstractRetryT)AbstractBackoffc                        e Zd Zej                  Zeeffdddedee	e
   df   f fdZdedefd	Z	 	 dd
eg ee   f   deeegef   eeegef   f   deeegef      dedef
dZ xZS )Retrybackoffr   retriessupported_errors.c                 (    t         |   |||       y N)super__init__)selfr   r   r   	__class__s       Q/opt/lhia/marcimex/agent/venv/lib/python3.12/site-packages/redis/asyncio/retry.pyr   zRetry.__init__   s     	'+;<    otherreturnc                     t        |t              st        S | j                  |j                  k(  xrF | j                  |j                  k(  xr+ t        | j                        t        |j                        k(  S r   )
isinstancer   NotImplemented_backoff_retriesset_supported_errors)r   r    s     r   __eq__zRetry.__eq__%   sc    %'!! MMU^^+ L/LD**+s53J3J/KK	
r   dofailis_retryablewith_failure_countc                   K   | j                   j                          d}	 	  |        d{   S 7 # | j                  $ r}|r	 ||      s |dz  }|r |||       d{  7   n ||       d{  7   | j                  dk\  r|| j                  kD  r|| j                   j	                  |      }|dkD  rt        |       d{  7   Y d}~nd}~ww xY ww)a  
        Execute an operation that might fail and returns its result, or
        raise the exception that was thrown depending on the `Backoff` object.
        `do`: the operation to call. Expects no argument.
        `fail`: the failure handler, expects the last error that was thrown
        ``is_retryable``: optional function to determine if an error is retryable
        ``with_failure_count``: if True, the failure count is passed to the failure handler
        r   N   )r%   resetr(   r&   computer   )r   r*   r+   r,   r-   failureserrorr   s           r   call_with_retryzRetry.call_with_retry/   s     $ 	)Tz!z)) )U(;A%uh///u+%%==A%(T]]*BK--//9Q;.(() s\   C
2 02 C2 CCA" C1A42ACCCCCC)NF)__name__
__module____qualname__r   __hash__r   r   intr	   r
   r   r   r   boolr)   r   r   r   r   	Exceptionr   r4   __classcell__)r   s   @r   r   r      s    %%H :
		="	= 	=  Z 0# 56		=
C 
D 
" ?C#(%)R1%&%) i[#%&i%s*+-
%) xT(9:;%) !%) 
%)r   r   N)asyncior   typingr   r   r   r   r   r	   r
   r   r   redis.exceptionsr   r   r   redis.retryr   r   redis.backoffr   r    r   r   <module>rC      sC    
 
 
 G F %CL-=)M*% =)r   