o
    ê6Wj”  ã                   @   s®   d dl Z d dlZd dlmZ d dlmZ ejrd dlmZ G dd„ deƒZejeej	dgej
e f f ZG dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZG dd„ deƒZdS )é    N)Ú_utils)Ú
retry_base)ÚRetryCallStatec                   @   sp   e Zd ZdZejdddefdd„ƒZ					dd
d„Z					ddd„Z					ddd„Z
				ddd„ZdS )Úasync_retry_basez/Abstract base class for async retry strategies.Úretry_stater   Úreturnc                 Ã   s   �d S ©N© ©Úselfr   r	   r	   úe/home/esfera/Documents/content_generation/venv/lib/python3.10/site-packages/tenacity/asyncio/retry.pyÚ__call__   s   €zasync_retry_base.__call__Úotherú*typing.Union[retry_base, async_retry_base]Ú	retry_allc                 C   ó
   t | |ƒS r   ©r   ©r   r   r	   r	   r   Ú__and__!   ó   
zasync_retry_base.__and__c                 C   ó
   t || ƒS r   r   r   r	   r	   r   Ú__rand__&   r   zasync_retry_base.__rand__Ú	retry_anyc                 C   r   r   ©r   r   r	   r	   r   Ú__or__+   r   zasync_retry_base.__or__c                 C   r   r   r   r   r	   r	   r   Ú__ror__0   r   zasync_retry_base.__ror__N)r   r   r   r   )r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚabcÚabstractmethodÚboolr   r   r   r   r   r	   r	   r	   r   r      s0    ÿ
þÿ
þÿ
þÿþr   r   c                   @   sF   e Zd ZdZdejegeje f ddfdd„Z	dddefd	d
„Z
dS )Úretry_if_exceptionzARetry strategy that retries if an exception verifies a predicate.Ú	predicater   Nc                 C   ó
   || _ d S r   ©r$   ©r   r$   r	   r	   r   Ú__init__>   r   zretry_if_exception.__init__r   r   c                 Ã   sJ   �|j d u r
tdƒ‚|j jr#|j  ¡ }|d u rtdƒ‚|  |¡I d H S dS )Nú(__call__() called before outcome was setz(outcome failed but the exception is NoneF)ÚoutcomeÚRuntimeErrorÚfailedÚ	exceptionr$   )r   r   r-   r	   r	   r   r   C   s   €

zretry_if_exception.__call__)r   r   r   r   ÚtypingÚCallableÚBaseExceptionÚ	Awaitabler"   r(   r   r	   r	   r	   r   r#   ;   s    ÿ
þr#   c                   @   sH   e Zd ZdZdejejgeje f ddfdd„Z	dddefd	d
„Z
dS )Úretry_if_resultz+Retries if the result verifies a predicate.r$   r   Nc                 C   r%   r   r&   r'   r	   r	   r   r(   S   r   zretry_if_result.__init__r   r   c                 Ã   s6   �|j d u r
tdƒ‚|j js|  |j  ¡ ¡I d H S dS )Nr)   F)r*   r+   r,   r$   Úresultr
   r	   r	   r   r   X   s   €
zretry_if_result.__call__)r   r   r   r   r.   r/   ÚAnyr1   r"   r(   r   r	   r	   r	   r   r2   P   s    ÿ
þr2   c                   @   ó>   e Zd ZdZdejeef ddfdd„Zddde	fd	d
„Z
dS )r   z1Retries if any of the retries condition is valid.Úretriesr   Nc                 G   r%   r   ©r6   ©r   r6   r	   r	   r   r(   e   ó   
zretry_any.__init__r   r   c                 Ã   s8   �d}| j D ]}|pt |¡|ƒI d H }|r |S q|S )NF©r6   r   Úwrap_to_async_func©r   r   r3   Úrr	   r	   r   r   h   ó   €
þzretry_any.__call__©r   r   r   r   r.   ÚUnionr   r   r(   r"   r   r	   r	   r	   r   r   b   ó    r   c                   @   r5   )r   z/Retries if all the retries condition are valid.r6   r   Nc                 G   r%   r   r7   r8   r	   r	   r   r(   t   r9   zretry_all.__init__r   r   c                 Ã   s8   �d}| j D ]}|ot |¡|ƒI d H }|s |S q|S )NTr:   r<   r	   r	   r   r   w   r>   zretry_all.__call__r?   r	   r	   r	   r   r   q   rA   r   )r    r.   Útenacityr   r   ÚTYPE_CHECKINGr   r   r@   r/   r1   r"   Ú
RetryBaseTr#   r2   r   r   r	   r	   r	   r   Ú<module>   s   ÿ