
    Oǻi                         d dl Z d dlZ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mZ d dlmZmZ  ed      Z eded      Zerd d	lmZ  G d
 dee   e j.                        Z G d dee         Zy)    N)sleep)
TYPE_CHECKINGAnyCallableGenericIterableOptionalTupleTypeTypeVarUnion)ConnectionErrorTimeoutErrorTET)bound	covariant)AbstractBackoffc                       e Zd ZU dZeee   df   ed<   dddedeee   df   fdZ	e
j                  d	ed
efd       Zd
efdZdeee      d
dfdZd
efdZded
dfdZy)AbstractRetryz0Retry a specific number of times after a failure._supported_errorsbackoffr   retriessupported_errorsc                 .    || _         || _        || _        y)a'  
        Initialize a `Retry` object with a `Backoff` object
        that retries a maximum of `retries` times.
        `retries` can be negative to retry forever.
        You can specify the types of supported errors which trigger
        a retry with the `supported_errors` parameter.
        N)_backoff_retriesr   )selfr   r   r   s       I/opt/lhia/marcimex/agent/venv/lib/python3.12/site-packages/redis/retry.py__init__zAbstractRetry.__init__   s      !1    otherreturnc                     t         S N)NotImplementedr   r"   s     r   __eq__zAbstractRetry.__eq__0   s    r!   c                 l    t        | j                  | j                  t        | j                        f      S r%   )hashr   r   	frozensetr   r   s    r   __hash__zAbstractRetry.__hash__4   s'    T]]DMM9T=S=S3TUVVr!   specified_errorsNc                 b    t        t        | j                  t        |      z               | _        y)zM
        Updates the supported errors with the specified error types
        N)tuplesetr   )r   r.   s     r   update_supported_errorsz%AbstractRetry.update_supported_errors7   s*     "'&&/?)@@A"
r!   c                     | j                   S )z,
        Get the number of retries.
        r   r,   s    r   get_retrieszAbstractRetry.get_retries?   s     }}r!   valuec                     || _         y)z,
        Set the number of retries.
        Nr4   )r   r6   s     r   update_retrieszAbstractRetry.update_retriesE   s     r!   )__name__
__module____qualname____doc__r
   r   r   __annotations__intr    abcabstractmethodr   boolr(   r-   r   r2   r5   r8    r!   r   r   r      s    :T!Wc\**2"2 2  Q-	2" 	C D  W# W
a8I 
d 
S C D r!   r   c                        e Zd Zej                  Zeeej                  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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 )Retryr   r   r   r   .c                 (    t         |   |||       y r%   )superr    )r   r   r   r   	__class__s       r   r    zRetry.__init__O   s     	'+;<r!   r"   r#   c                     t        |t              st        S | j                  |j                  k(  xrF | j                  |j                  k(  xr+ t        | j                        t        |j                        k(  S r%   )
isinstancerD   r&   r   r   r1   r   r'   s     r   r(   zRetry.__eq__[   sc    %'!! MMU^^+ L/LD**+s53J3J/KK	
r!   dofailis_retryablewith_failure_countc                 d   | j                   j                          d}	 	  |       S # | j                  $ ry}|r	 ||      s |dz  }|r
 |||       n ||       | j                  dk\  r|| j                  kD  r|| j                   j	                  |      }|dkD  rt        |       Y d}~nd}~ww xY 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   rJ   rK   rL   rM   failureserrorr   s           r   call_with_retryzRetry.call_with_retrye   s     	#t)) #U(;A%)K==A%(T]]*BK--//9Q;'N# s   & B.A/B))B.)NF)r9   r:   r;   r   r-   r   r   sockettimeoutr>   r
   r   	Exceptionr    r   rA   r(   r   r   r   r	   rT   __classcell__)rG   s   @r   rD   rD   L   s    %%H NN9
	
="
= 
=  Y 45	
=
C 
D 
 ?C#("#RUO"# Hi[#-.)S9I39N0OOP"# xT(9:;	"#
 !"# 
"#r!   rD   )r?   rU   timer   typingr   r   r   r   r   r	   r
   r   r   r   redis.exceptionsr   r   r   rW   r   redis.backoffr   ABCr   rD   rB   r!   r   <module>r^      sg    
     ;CLCyD1-/GAJ /d;#M)$ ;#r!   