� ��gq���ddlZddlZddlZddlmZejrddlmZGd�dej��Zej eej dgej e e fffZ Gd�de��ZGd �d e��ZGd �d e��ZGd �de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZdS)�N)�_utils)�RetryCallStatec�j�eZdZdZejdddefd���Zd d�Zddde j d fd �Z d S) � wait_basez(Abstract base class for wait strategies.� retry_stater�returnc��dS�N���selfrs �]/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/tenacity/wait.py�__call__zwait_base.__call__s�� ���other� wait_combinec�"�t||��Sr )r�r rs r�__add__zwait_base.__add__"s���D�%�(�(�(r)rrc�<�|dkr|S|�|��S�Nr)rrs r�__radd__zwait_base.__radd__%s"�� �A�:�:��K��|�|�E�"�"�"rN)rrrr) �__name__� __module__� __qualname__�__doc__�abc�abstractmethod�floatrr�typing�Unionrr rrrrs�������2�2��� �$4� �� � � ��� �)�)�)�)�#�k�#�f�l�;V�.W�#�#�#�#�#�#rrrc�<�eZdZdZdejddfd�Zdddefd�ZdS) � wait_fixedzCWait strategy that waits a fixed amount of time between each retry.�waitrNc�8�tj|��|_dSr )r� to_secondsr#)r r$s r�__init__zwait_fixed.__init__4s�� �+�D�1�1����rrrc��|jSr )r#r s rrzwait_fixed.__call__7s ����r� rrrrr�time_unit_typer'rrr rrr#r#1sb������M�M�2�V�2�2�t�2�2�2�2��$4��������rr#c�$��eZdZdZd�fd� Z�xZS)� wait_nonez7Wait strategy that doesn't wait at all before retrying.rNc�J��t���d��dSr)�superr')r � __class__s �rr'zwait_none.__init__>s!��� ����������r)rN)rrrrr'� __classcell__�r/s@rr,r,;sC�������A�A����������rr,c�N�eZdZdZ d dejdejddfd�Zd d defd �ZdS) � wait_randomzAWait strategy that waits a random amount of time between min/max.r��min�maxrNc�j�tj|��|_tj|��|_dSr )rr&�wait_random_min�wait_random_max)r r5r6s rr'zwait_random.__init__Es0�� &�0��5�5���%�0��5�5����rrrc�X�|jtj��|j|jz zzSr )r8�randomr9r s rrzwait_random.__call__Ks+���#� �M�O�O�t�3�d�6J�J� K� � r)rr4r)r rrr3r3Bs{������K�K�LM�6�6��(�6�39�3H�6� �6�6�6�6�  �$4� �� � � � � � rr3c�2�eZdZdZdeddfd�Zdddefd�ZdS) rz#Combine several waiting strategies.� strategiesrNc��||_dSr )� wait_funcs�r r=s rr'zwait_combine.__init__T� ��$����rrrc�D��t�fd�|jD����S)Nc3�0�K�|]}|����V��dS)�rNr )�.0�xrs �r� <genexpr>z(wait_combine.__call__.<locals>.<genexpr>Xs0�����G�G�!�1�1��-�-�-�G�G�G�G�G�Gr)�sumr?r s `rrzwait_combine.__call__Ws(����G�G�G�G�t��G�G�G�G�G�Gr�rrrrrr'rrr rrrrQsg������-�-�%�I�%�$�%�%�%�%�H�$4�H��H�H�H�H�H�Hrrc�2�eZdZdZdeddfd�Zdddefd�ZdS) � wait_chaina�Chain two or more waiting strategies. If all strategies are exhausted, the very last strategy is used thereafter. For example:: @retry(wait=wait_chain(*[wait_fixed(1) for i in range(3)] + [wait_fixed(2) for j in range(5)] + [wait_fixed(5) for k in range(4))) def wait_chained(): print("Wait 1s for 3 attempts, 2s for 5 attempts and 5s thereafter.") r=rNc��||_dSr )r=r@s rr'zwait_chain.__init__krArrrc��tt|jd��t|j����}|j|dz }||���S)Nr4rD)r5r6�attempt_number�lenr=)r r� wait_func_no� wait_funcs rrzwait_chain.__call__nsL���3�{�9�1�=�=�s�4�?�?S�?S�T�T� ��O�L�1�$4�5� ��y�[�1�1�1�1rrIr rrrKrK[sc������ � �%�I�%�$�%�%�%�%�2�$4�2��2�2�2�2�2�2rrKc �j�eZdZdZddejfdejdejdejddfd �Zd d defd �Z dS) �wait_incrementingz�Wait an incremental amount of time after each attempt. Starting at a starting value and incrementing by a value for each attempt (and restricting the upper limit to some maximum value). r�d�start� incrementr6rNc��tj|��|_tj|��|_tj|��|_dSr )rr&rUrVr6)r rUrVr6s rr'zwait_incrementing.__init__{s>�� �&�u�-�-�� ��*�9�5�5����$�S�)�)����rrrc�|�|j|j|jdz zz}tdt ||j����S�Nr4r)rUrVrNr6r5)r r�results rrzwait_incrementing.__call__�s9����t�~��1K�a�1O�P�Q���1�c�&�$�(�+�+�,�,�,r) rrrrr�MAX_WAITr*r'rrr rrrSrSts���������()�+.�%+�_� *�*��$�*��(�*�� "� *� � *�*�*�*�-�$4�-��-�-�-�-�-�-rrSc ��eZdZdZdejddfdejee fdej dejee fdej d d f d �Z d d d e fd�Z d S)�wait_exponentialaWait strategy that applies exponential backoff. It allows for a customized multiplier and an ability to restrict the upper and lower limits to some maximum and minimum value. The intervals are fixed (i.e. there is no jitter), so this strategy is suitable for balancing retries against latency when a required resource is unavailable for an unknown duration, but *not* suitable for resolving contention between multiple processes for a shared resource. Use wait_random_exponential for the latter case. r4�r� multiplierr6�exp_baser5rNc��||_tj|��|_tj|��|_||_dSr )r_rr&r5r6r`)r r_r6r`r5s rr'zwait_exponential.__init__�s:��%����$�S�)�)����$�S�)�)��� �� � � rrrc��� |j|jdz z}|j|z}n#t$r |jcYSwxYwt t d|j��t ||j����SrY)r`rNr_� OverflowErrorr6r5)r r�exprZs rrzwait_exponential.__call__�sw�� ��-�K�$>��$B�C�C��_�s�*�F�F��� � � ��8�O�O�O� �����3�q�$�(�#�#�S����%:�%:�;�;�;s ��3�3) rrrrrr[r r!�intrr*r'rr rrr]r]�s������� � �01�%+�_�-.�%&� !� !��L��e��,� !�� "� !��,�s�E�z�*� !� � "� !� � !� !� !� !�<�$4�<��<�<�<�<�<�<rr]c�,��eZdZdZdddef�fd� Z�xZS)�wait_random_exponentialaRandom wait with exponentially widening window. An exponential backoff strategy used to mediate contention between multiple uncoordinated processes for a shared resource in distributed systems. This is the sense in which "exponential backoff" is meant in e.g. Ethernet networking, and corresponds to the "Full Jitter" algorithm described in this blog post: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ Each retry occurs at a random time in a geometrically expanding interval. It allows for a custom multiplier and an ability to restrict the upper limit of the random interval to some maximum value. Example:: wait_random_exponential(multiplier=0.5, # initial window 0.5s max=60) # max 60s timeout When waiting for an unavailable resource to become available again, as opposed to trying to resolve contention for a shared resource, the wait_exponential strategy (which uses a fixed interval) may be preferable. rrrc�|��t���|���}tj|j|��S)NrD)r.rr;�uniformr5)r r�highr/s �rrz wait_random_exponential.__call__�s1����w�w���K��8�8���~�d�h��-�-�-r)rrrrrrr0r1s@rrgrg�sV���������2.�$4�.��.�.�.�.�.�.�.�.�.�.rrgc �R�eZdZdZdejddfdededededd f d �Zd d defd �Zd S)�wait_exponential_jittera`Wait strategy that applies exponential backoff and jitter. It allows for a customized initial wait, maximum wait and jitter. This implements the strategy described here: https://cloud.google.com/storage/docs/retry-strategy The wait time is min(initial * 2**n + random.uniform(0, jitter), maximum) where n is the retry count. r4r^�initialr6r`�jitterrNc�>�||_||_||_||_dSr )rmr6r`rn)r rmr6r`rns rr'z wait_exponential_jitter.__init__�s$���� ���� �� ��� � � rrrc���tjd|j��} |j|jdz z}|j|z|z}n#t $r |j}YnwxYwtdt||j����S)Nrr4) r;rirnr`rNrmrcr6r5)r rrnrdrZs rrz wait_exponential_jitter.__call__�s������4�;�/�/�� ��-�K�$>��$B�C�C��\�C�'�&�0�F�F��� � � ��X�F�F�F� �����1�c�&�$�(�+�+�,�,�,s�<�A�A) rrrrrr[rr'rr rrrlrl�s������� � ���_��� � �� �� �� � � � � � � � �-�$4�-��-�-�-�-�-�-rrl)rr;r �tenacityr� TYPE_CHECKINGr�ABCrr!�Callablerre� WaitBaseTr#r,r3rrKrSr]rgrlr rr�<module>rvs<��" � � � � � � � � � � � ������� ��(�'�'�'�'�'�'�#�#�#�#�#���#�#�#�" �L� �v�� 0�1�6�<��s� �3K�K�L�L� � � �������������� ����  �  �  �  �  �)�  �  �  �H�H�H�H�H�9�H�H�H�2�2�2�2�2��2�2�2�2-�-�-�-�-� �-�-�-�,<�<�<�<�<�y�<�<�<�D.�.�.�.�.�.�.�.�.�>-�-�-�-�-�i�-�-�-�-�-r
Memory