
    Ii                         S SK r S SKrS SKrS SKrS SKJr  SSKJr  \ R                  " \	5      r
\SS SSS \
SS4	S jr\SS SSS \
SS4	S jrSS\SS SSS \
SS4S	 jrg)
    N)partial   	decoratorFc
           
         X#pU
(       a   U " 5       $ g! U Ga:  nU	b  U	" U5      (       a   SnAgU
S-  n
U
(       d  e Ub   U R                   R                  nO%! [         a    [        U R                   5      n Of = fUR	                  SR                  UR                  R                  UU R                   R                  X5      5        U(       a$  UR	                  [        R                  " 5       5        [        R                  " U5        X-  n[        U[        5      (       a  U[        R                  " U6 -  nOX-  nUb  [!        X5      n SnAOSnAff = fU
(       a  GMW  g)a  
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.
:param on_exception: handler called when exception occurs. will be passed the captured
                     exception as an argument. further retries are stopped when handler
                     returns True. default: None
:returns: the result of the f function.
Nr   z*{}: {} in {}.{}, retrying in {} seconds...)func__qualname__AttributeErrorstrwarningformat	__class__
__module__	traceback
format_exctimesleep
isinstancetuplerandomuniformmin)f
exceptionstriesdelay	max_delaybackoffjitterloggerlog_tracebackon_exception_tries_delayefunc_qualnames                 //venv/lib/python3.13/site-packages/retry/api.py__retry_internalr)      s/   ( F
	03J   	0'??aKF!0%&VV%8%8M% 0$'KM0KRRSTS^S^SkSkmn vv00- I J NN9#7#7#9:JJvF&%((&..&11 $V/9	0 &s>    EEE AEA96E8A99CEEc	           
      F   ^ ^^^^^^^^ [         UUU UUUUUU4	S j5       n	U	$ )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.
:param on_exception: handler called when exception occurs. will be passed the captured
                     exception as an argument. further retries are stopped when handler
                     returns True. default: None
:returns: a retry decorator.
c                    >	 U(       a  UO	[        5       nU(       a  UO	[        5       n[        [        U /UQ70 UD6TTTTTTT
T	T5
      $ )Nlistdictr)   r   )r   fargsfkwargsargskwargsr   r   r   r    r"   r!   r   r#   r   s        r(   retry_decoratorretry.<locals>.retry_decoratorV   sP    u46# ;D ;F ;ZPUW`bikq &|E 	E    r   )
r   r   r   r   r   r    r!   r"   r#   r3   s
   ````````` r(   retryr6   C   s(    & E E E r5   c                     U(       a  UO	[        5       nU(       a  UO	[        5       n[        [        U /UQ70 UD6X4XVXxU	X5
      $ )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.
:param on_exception: handler called when exception occurs. will be passed the captured
                     exception as an argument. further retries are stopped when handler
                     returns True. default: None
:returns: the result of the f function.
r,   )r   r/   r0   r   r   r   r   r   r    r!   r"   r#   r1   r2   s                 r(   
retry_callr8   `   sE    , 5tvDWTVFGA777E^eou)9 9r5   )loggingr   r   r   	functoolsr   compatr   	getLogger__name__logging_logger	Exceptionr)   r6   r8    r5   r(   <module>rA      s         ""8, $-Ba4YZcd*%d40n bT1UV_mD: dyRS_cmneRV9r5   