o
    ChX                     @   s   d dl mZ d dlmZmZmZmZmZmZm	Z	 d dl
mZmZmZ d dlmZ e	dZer4d dlmZ G dd dee Zd	S )
    )sleep)TYPE_CHECKINGAny	AwaitableCallableTupleTypeTypeVar)ConnectionError
RedisErrorTimeoutError)AbstractRetryT)AbstractBackoffc                	       s   e Zd ZejZeeffdddedee	e
 df f fddZded	efd
dZdeg ee f dee
gef d	efddZ  ZS )Retrybackoffr   retriessupported_errors.c                    s   t  ||| d S N)super__init__)selfr   r   r   	__class__ e/var/www/html/myvaluetrips/my_value_trip_new/venv/lib/python3.10/site-packages/redis/asyncio/retry.pyr      s   	zRetry.__init__otherreturnc                 C   s:   t |tstS | j|jko| j|jkot| jt|jkS r   )
isinstancer   NotImplemented_backoff_retriesset_supported_errors)r   r   r   r   r   __eq__   s   

zRetry.__eq__dofailc              
      s   | j   d}	 z| I dH W S  | jyK } z.|d7 }||I dH  | jdkr0|| jkr0|| j |}|dkrAt|I dH  W Y d}~nd}~ww q	)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   TN   )r    resetr#   r!   computer   )r   r%   r&   failureserrorr   r   r   r   call_with_retry%   s"   
	zRetry.call_with_retry)__name__
__module____qualname__r   __hash__r
   r   intr   r   r   r   r   boolr$   r   r   r   r,   __classcell__r   r   r   r   r      s(    
r   N)asyncior   typingr   r   r   r   r   r   r	   redis.exceptionsr
   r   r   redis.retryr   r   redis.backoffr   r   r   r   r   r   <module>   s    $