
    ,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 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)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       P/var/www/html/langgraph-service/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__/   s    r    c                 l    t        | j                  | j                  t        | j                        f      S r$   )hashr   r   	frozensetr   r   s    r   __hash__zAbstractRetry.__hash__3   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_errors6   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.
        Nr3   )r   r5   s     r   update_retrieszAbstractRetry.update_retriesD   s     r    )__name__
__module____qualname____doc__r
   r   r   __annotations__intr   abcabstractmethodr   boolr'   r,   r   r1   r4   r7    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gef   deeegef      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__N   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$   )
isinstancerC   r%   r   r   r0   r   r&   s     r   r'   zRetry.__eq__Z   sc    %'!! MMU^^+ L/LD**+s53J3J/KK	
r    dofailis_retryablec                 L   | j                   j                          d}	 	  |       S # | j                  $ rm}|r	 ||      s |dz  } ||       | 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
        r      N)r   resetr   r   computer   )r   rI   rJ   rK   failureserrorr   s          r   call_with_retryzRetry.call_with_retryd   s     	#t)) 	#U(;AU==A%(T]]*BK--//9Q;'N	# s   & B"A#BB"r$   )r8   r9   r:   r   r,   r   r   sockettimeoutr=   r
   r   	Exceptionr   r   r@   r'   r   r   r	   rR   __classcell__)rF   s   @r   rC   rC   K   s    %%H NN9
	
="
= 
=  Y 45	
=
C 
D 
 ?C	#RUO# 	{C'(# xT(9:;	#
 
#r    rC   )r>   rS   timer   typingr   r   r   r   r   r	   r
   r   r   redis.exceptionsr   r   r   rU   r   redis.backoffr   ABCr   rC   rA   r    r   <module>r\      sg    
  
 
 
 ;CLCyD1-/GAJ /d3#M)$ 3#r    