o
    <‘ðiÓ	  ã                   @   sˆ   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mZ d dlmZ e
dƒZer8d dlmZ G dd„ dee ƒZd	S )
é    )Úsleep)	ÚTYPE_CHECKINGÚAnyÚ	AwaitableÚCallableÚOptionalÚTupleÚTypeÚTypeVarÚUnion)Ú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deg ee f deeegef eeegef f deeegef  de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__© úR/root/parts/websockify/install/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__NFÚdoÚfailÚis_retryableÚwith_failure_countc              
   Ã   s¾   �| j  ¡  d}	 z|ƒ I dH W S  | jy] } z@|r ||ƒs ‚ |d7 }|r/|||ƒI dH  n||ƒI dH  | jdkrB|| jkrB|‚| j  |¡}|dkrSt|ƒ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
        ``is_retryable``: optional function to determine if an error is retryable
        ``with_failure_count``: if True, the failure count is passed to the failure handler
        r   TNé   )r"   Úresetr%   r#   Úcomputer   )r   r'   r(   r)   r*   ÚfailuresÚerrorr   r   r   r   Úcall_with_retry/   s*   €
€òýzRetry.call_with_retry)NF)Ú__name__Ú
__module__Ú__qualname__r   Ú__hash__r   r   Úintr   r	   r   r   r   Úboolr&   r   r   r   r   Ú	Exceptionr   r0   Ú__classcell__r   r   r   r   r      s<    þüþýüøþÿÿýùø	÷r   N)Úasyncior   Útypingr   r   r   r   r   r   r	   r
   r   Úredis.exceptionsr   r   r   Úredis.retryr   r   Úredis.backoffr   r   r   r   r   r   Ú<module>   s    ,