
    i'              	           d dl Z d dlZd dlZd dlmZ d dlmZ  e j        e          Z	e
dd ddd e	fdZe
dd ddd e	fdZdde
dd ddd e	f	dZdS )	    N)partial	decorator   c                 D   ||}	}|r	  |             S # |$ r}
|dz  }|s ||                     d|
|	           t          j        |	           |	|z  }	t          |t                    r|	t          j        | z  }	n|	|z  }	|t          |	|          }	Y d}
~
nd}
~
ww xY w|dS dS )aW  
    Executes a function and retries it if it failed.

    :param f: the function to execute.
    :param exceptions: an exception or a tuple of exceptions to catch. default: Exception.
    :param tries: the maximum number of attempts. default: -1 (infinite).
    :param delay: initial delay between attempts. default: 0.
    :param max_delay: the maximum value of delay. default: None (no limit).
    :param backoff: multiplier applied to delay between attempts. default: 1 (no backoff).
    :param jitter: extra seconds added to delay between attempts. default: 0.
                   fixed if a number, random if a range tuple (min, max)
    :param logger: logger.warning(fmt, error, delay) will be called on failed attempts.
                   default: retry.logging_logger. if None, logging is disabled.
    :returns: the result of the f function.
    r   Nz%s, retrying in %s seconds...)warningtimesleep
isinstancetuplerandomuniformmin)f
exceptionstriesdelay	max_delaybackoffjitterlogger_tries_delayes              4/usr/local/lib/python3.11/dist-packages/retry/api.py__retry_internalr      s    " EFF
 0	0133J 	0 	0 	0aKF !>6JJJJvgF&%(( !&.&11& $VY//#	0  0 0 0 0 0s   	 BA8BBc                 D     t            fd            }|S )a
  Returns a retry decorator.

    :param exceptions: an exception or a tuple of exceptions to catch. default: Exception.
    :param tries: the maximum number of attempts. default: -1 (infinite).
    :param delay: initial delay between attempts. default: 0.
    :param max_delay: the maximum value of delay. default: None (no limit).
    :param backoff: multiplier applied to delay between attempts. default: 1 (no backoff).
    :param jitter: extra seconds added to delay between attempts. default: 0.
                   fixed if a number, random if a range tuple (min, max)
    :param logger: logger.warning(fmt, error, delay) will be called on failed attempts.
                   default: retry.logging_logger. if None, logging is disabled.
    :returns: a retry decorator.
    c           
          |r|nt                      }|r|nt                      }t          t          | g|R i |
	          S )Nlistdictr   r   )r   fargsfkwargsargskwargsr   r   r   r   r   r   r   s        r   retry_decoratorzretry.<locals>.retry_decoratorE   sf    )uu466#/ ;D ; ; ;F ; ;ZPUW`bikq &( ( 	(    r   )r   r   r   r   r   r   r   r'   s   ``````` r   retryr)   6   sT     ( ( ( ( ( ( ( ( ( ( Y( r(   c
           
          |r|nt                      }
|r|nt                      }t          t          | g|
R i ||||||||	          S )a  
    Calls a function and re-executes it if it failed.

    :param f: the function to execute.
    :param fargs: the positional arguments of the function to execute.
    :param fkwargs: the named arguments of the function to execute.
    :param exceptions: an exception or a tuple of exceptions to catch. default: Exception.
    :param tries: the maximum number of attempts. default: -1 (infinite).
    :param delay: initial delay between attempts. default: 0.
    :param max_delay: the maximum value of delay. default: None (no limit).
    :param backoff: multiplier applied to delay between attempts. default: 1 (no backoff).
    :param jitter: extra seconds added to delay between attempts. default: 0.
                   fixed if a number, random if a range tuple (min, max)
    :param logger: logger.warning(fmt, error, delay) will be called on failed attempts.
                   default: retry.logging_logger. if None, logging is disabled.
    :returns: the result of the f function.
    r    )r   r#   r$   r   r   r   r   r   r   r   r%   r&   s               r   
retry_callr+   O   s`    ( %55tvvD+WWTVVFGA777777UES\^egmouvvvr(   )loggingr   r
   	functoolsr   retry.compatr   	getLogger__name__logging_logger	Exceptionr   r)   r+    r(   r   <module>r4      s             " " " " " " #"8,, $-Ba4YZcd*&0 &0 &0 &0R bT1UV_m    2 dyRS_cmn$w w w w w wr(   