
    hM                         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 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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       m/var/www/fastuser/data/www/generator.snapmosaic.io/flask_app/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__)   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_errors,   s*     "'&&/?)@@A"
r   c                     | j                   S )z,
        Get the number of retries.
        r   r*   s    r   get_retrieszAbstractRetry.get_retries4   s     }}r   valuec                     || _         y)z,
        Set the number of retries.
        Nr2   )r   r4   s     r   update_retrieszAbstractRetry.update_retries:   s     r   )__name__
__module____qualname____doc__r	   r
   r   __annotations__intr   abcabstractmethodr   boolr&   r+   r   r0   r3   r6    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
eg ef   d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__D   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#   )
isinstancerB   r$   r   r   r/   r   r%   s     r   r&   zRetry.__eq__P   sc    %'!! MMU^^+ L/LD**+s53J3J/KK	
r   dofailc                 6   | j                   j                          d}	 	  |       S # | j                  $ rb}|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   rH   rI   failureserrorr   s         r   call_with_retryzRetry.call_with_retryZ   s     		#t)) #AU==A%(T]]*BK--//9Q;'N# s   & BABB)r7   r8   r9   r   r+   r   r   sockettimeoutr<   r	   r
   	Exceptionr   r   r?   r&   r   r   rP   __classcell__)rE   s   @r   rB   rB   A   s    %%H NN9
	
="
= 
=  Y 45	
=
C 
D 
#RUO# 	{C'(# 
	#r   rB   )r=   rQ   timer   typingr   r   r   r   r   r	   r
   r   redis.exceptionsr   r   r   rS   r   redis.backoffr   ABCr   rB   r@   r   r   <module>rZ      s_    
   X X X :CLCyD1-/GAJ /d0#M)$ 0#r   