
    h                         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dS )    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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       K/var/www/html/auto_sub_bot/venv/lib/python3.11/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                 ^    t          | j        | j        t          | j                  f          S r$   )hashr   r   	frozensetr   r   s    r   __hash__zAbstractRetry.__hash__3   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_errors6   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.
        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 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gef         deeegef                  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__N   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$   )
isinstancerC   r%   r   r   r0   r   r&   s     r   r'   zRetry.__eq__Z   sc    %'' 	"!! MU^+ L/LD*++s53J/K/KK	
r    Ndofailis_retryablec                 J   | j                                          d}	 	  |            S # | j        $ ro}|r ||          s |dz  } ||           | 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
        r   T   N)r   resetr   r   computer   )r   rI   rJ   rK   failureserrorr   s          r   call_with_retryzRetry.call_with_retryd   s     		##rtt) 	# 	# 	# U(;(; AU=A%%(T]*B*BK-//99Q;;'NNN	#	#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 N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\      sZ   



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