o
    ChM                     @   s   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dZer=d d	lmZ G d
d dee e jZG dd dee ZdS )    N)sleep)TYPE_CHECKINGAnyCallableGenericIterableTupleTypeTypeVar)ConnectionErrorTimeoutErrorTET)bound	covariant)AbstractBackoffc                   @   s   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d	Z	e
jd
edefddZdefddZdeee  ddfddZdefddZdeddfddZdS )AbstractRetryz0Retry a specific number of times after a failure._supported_errorsbackoffr   retriessupported_errorsc                 C   s   || _ || _|| _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    r   ]/var/www/html/myvaluetrips/my_value_trip_new/venv/lib/python3.10/site-packages/redis/retry.py__init__   s   
zAbstractRetry.__init__otherreturnc                 C   s   t S N)NotImplementedr   r   r   r   r   __eq__%   s   zAbstractRetry.__eq__c                 C   s   t | j| jt| jfS r    )hashr   r   	frozensetr   r   r   r   r   __hash__)   s   zAbstractRetry.__hash__specified_errorsNc                 C   s   t t| jt | | _dS )zM
        Updates the supported errors with the specified error types
        N)tuplesetr   )r   r(   r   r   r   update_supported_errors,   s   
z%AbstractRetry.update_supported_errorsc                 C   s   | j S )z,
        Get the number of retries.
        r   r&   r   r   r   get_retries4   s   zAbstractRetry.get_retriesvaluec                 C   s
   || _ dS )z,
        Set the number of retries.
        Nr,   )r   r.   r   r   r   update_retries:   s   
zAbstractRetry.update_retries)__name__
__module____qualname____doc__r   r	   r   __annotations__intr   abcabstractmethodr   boolr#   r'   r   r+   r-   r/   r   r   r   r   r      s    
 
r   c                	       s   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dZded	efd
dZdeg ef deegef d	efddZ  ZS )Retryr   r   r   r   .c                    s   t  ||| d S r    )superr   r   	__class__r   r   r   D   s   
zRetry.__init__r   r   c                 C   s:   t |tstS | j|jko| j|jkot| jt|jkS r    )
isinstancer9   r!   r   r   r*   r   r"   r   r   r   r#   P   s   

zRetry.__eq__dofailc              
   C   s   | j   d}	 z| W S  | jyA } z(|d7 }|| | jdkr)|| jkr)|| j |}|dkr7t| 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   T   N)r   resetr   r   computer   )r   r>   r?   failureserrorr   r   r   r   call_with_retryZ   s    
zRetry.call_with_retry)r0   r1   r2   r   r'   r   r   sockettimeoutr5   r   r	   	Exceptionr   r   r8   r#   r   r   rE   __classcell__r   r   r;   r   r9   A   s*    

r9   )r6   rF   timer   typingr   r   r   r   r   r   r	   r
   redis.exceptionsr   r   r   rH   r   redis.backoffr   ABCr   r9   r   r   r   r   <module>   s    (2