
    /
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dS )    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dS )AbstractRetryz0Retry a specific number of times after a failure._supported_errorsbackoffr   retriessupported_errorsc                 0    || _         || _        || _        dS )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       C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\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                 ^    t          | j        | j        t          | j                  f          S r%   )hashr   r   	frozensetr   r   s    r   __hash__zAbstractRetry.__hash__4   s&    T]DM9T=S3T3TUVVVr!   specified_errorsNc                 r    t          t          | j        t          |          z                       | _        dS )zM
        Updates the supported errors with the specified error types
        N)tuplesetr   )r   r.   s     r   update_supported_errorsz%AbstractRetry.update_supported_errors7   s8     "'&/?)@)@@AA"
 "
r!   c                     | j         S )z,
        Get the number of retries.
        r   r,   s    r   get_retrieszAbstractRetry.get_retries?   s     }r!   valuec                     || _         dS )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 2 2 2" 	C D    W# W W 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                 N    t                                          |||           d S 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    o9| j        |j        k    o)t          | j                  t          |j                  k    S r%   )
isinstancerD   r&   r   r   r1   r   r'   s     r   r(   zRetry.__eq__[   sc    %'' 	"!! MU^+ L/LD*++s53J/K/KK	
r!   NFdofailis_retryablewith_failure_countc                 h   | j                                          d}	 	  |            S # | j        $ r~}|r ||          s |dz  }|r |||           n ||           | j        dk    r|| j        k    r|| j                             |          }|dk    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   T   N)r   resetr   r   computer   )r   rJ   rK   rL   rM   failureserrorr   s           r   call_with_retryzRetry.call_with_retrye   s     		##rtt) # # # U(;(; A%  D))))DKKK=A%%(T]*B*BK-//99Q;;'NNN#	#s   	( 
B0A4B++B0)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   s8       %H N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^      sd   



                               ; : : : : : : :GCLLGCyD111 .------/ / / / /GAJ / / /d;# ;# ;# ;# ;#M)$ ;# ;# ;# ;# ;#r!   