ó
    Ú°›jn9  ã                   ó`  • S SK r S SKrS SKrS SKJr  S SKJrJrJrJ	r	J
r
  \R                  " \5      rS\\\
\	/0rS rS rSS jrSS jrSS	 jrS
 rS rS r " S S5      r " S S5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)é    N)Úcrc32)ÚChecksumErrorÚConnectionClosedErrorÚConnectionErrorÚEndpointConnectionErrorÚReadTimeoutErrorÚGENERAL_CONNECTION_ERRORc                 óz   • U S:X  a  [         R                   " 5       n OU S::  a  [        SU  35      eXUS-
  -  -  nU$ )a  Calculate time to sleep based on exponential function.

The format is::

    base * growth_factor ^ (attempts - 1)

If ``base`` is set to 'rand' then a random number between
0 and 1 will be used as the base.
Base must be greater than 0, otherwise a ValueError will be
raised.

Úrandr   z.The 'base' param must be greater than 0, got: é   )ÚrandomÚ
ValueError)ÚbaseÚgrowth_factorÚattemptsÚtime_to_sleeps       ÚR/home/mande/repo/quber/.venv/lib/python3.13/site-packages/botocore/retryhandler.pyÚdelay_exponentialr   +   sM   € ð ˆvƒ~Ü�}Š}‹‰Ø	�‹ÜØ<¸T¸FÐCó
ð 	
ð ¨h¸©lÑ;Ñ<€MØÐó    c                 ó4   • [         R                  " [        XS9$ )z›Create an exponential delay function based on the attempts.

This is used so that you only have to pass it the attempts
parameter to calculate the delay.

©r   r   )Ú	functoolsÚpartialr   r   s     r   Ú!create_exponential_delay_functionr   B   s   € ô ×ÒÜ ñð r   c                 ó8   • [        XS9n[        XS9n[        X#S9$ )N)Úoperation_name)ÚcheckerÚaction)Ú create_checker_from_retry_configÚcreate_retry_action_from_configÚRetryHandler)Úconfigr   r   r   s       r   Úcreate_retry_handlerr#   N   s+   € Ü.Øñ€Gô -Øñ€Fô  Ñ7Ð7r   c                 óF   • U S   S   nUS   S:X  a  [        US   US   S9$ g )NÚ__default__ÚdelayÚtypeÚexponentialr   r   r   )r   )r"   r   Údelay_configs      r   r    r    X   sB   € ð
 ˜-Ñ(¨Ñ1€LØ�FÑ˜}Ó,Ü0Ø˜fÑ%Ø& Ñ7ñ
ð 	
ð -r   c                 ó"  • / nS n/ nSU ;   ae  U S   R                  S/ 5      nU S   S   nU HB  nXV   nUR                  [        U5      5        [        U5      nUc  M1  UR	                  U5        MD     Uba  U R                  U5      bO  X   S   n	U	 HB  nUR                  [        X–   5      5        [        X–   5      nUc  M1  UR	                  U5        MD     [        U5      S:X  a  [        US   US9$ [        U5      n
[        U
U[        U5      S9$ )Nr%   ÚpoliciesÚmax_attemptsr   r   )r,   )r,   Úretryable_exceptions)	ÚgetÚappendÚ_create_single_checkerÚ_extract_retryable_exceptionÚextendÚlenÚMaxAttemptsDecoratorÚMultiCheckerÚtuple)r"   r   Úcheckersr,   r-   r+   ÚkeyÚcurrent_configÚretry_exceptionÚoperation_policiesÚmulti_checkers              r   r   r   e   s0  € Ø€HØ€LØÐØ˜ÓØ˜-Ñ(×,Ñ,¨Z¸Ó<ˆØ˜mÑ,¨^Ñ<ˆÛˆCØ%™]ˆNØ�O‰OÔ2°>ÓBÔCÜ:¸>ÓJˆOØÓ*Ø$×+Ñ+¨OÖ<ñ ð Ñ! f§j¡j°Ó&@Ñ&LØ#Ñ3°JÑ?ÐÛ%ˆCØ�O‰OÔ2Ð3EÑ3JÓKÔLÜ:Ø"Ñ'óˆOð Ó*Ø$×+Ñ+¨OÖ<ñ &ô ˆ8ƒ}˜Óä# H¨Q¡K¸lÑKÐKä$ XÓ.ˆÜ#ØØ%Ü!&Ð';Ó!<ñ
ð 	
r   c                 ó^   • SU S   ;   a  [        U S   S   5      $ SU S   ;   a
  [        5       $ g )NÚresponseÚapplies_whenÚsocket_errors)Ú_create_single_response_checkerÚExceptionRaiser)r"   s    r   r0   r0   ‡   sF   € Ø�V˜NÑ+Ó+Ü.Ø�>Ñ" :Ñ.ó
ð 	
ð 
˜F >Ñ2Ó	2ÜÓ Ð ð 
3r   c                 ó˜   • SU ;   a  [        U S   U S   S9nU$ SU ;   a  [        U S   S9nU$ SU ;   a  [        U S   S9nU$ [        S5      e)NÚservice_error_codeÚhttp_status_code)Ústatus_codeÚ
error_code)rF   Ú	crc32body)ÚheaderzUnknown retry policy)ÚServiceErrorCodeCheckerÚHTTPStatusCodeCheckerÚCRC32Checkerr   )r>   r   s     r   rA   rA   �   s   € Ø˜xÓ'Ü)Ø Ð!3Ñ4ØÐ 4Ñ5ñ
ˆð €Nð 
˜xÓ	'Ü'Ø Ð!3Ñ4ñ
ˆð €Nð 
˜Ó	 Ü h¨{Ñ&;Ñ<ˆð €Nô Ð/Ó0Ð0r   c                 ó¤   • U S   nSUR                  S0 5      ;   a  [        /$ SU;   a(  / nUS    H  nUR                  [        U   5        M     U$ g )Nr?   rH   r>   r@   )r.   r   r2   ÚEXCEPTION_MAP)r"   r?   Ú
exceptionsÚnames       r   r1   r1   ¢   sc   € Ø˜.Ñ)€LØ�l×&Ñ& z°2Ó6Ó6ÜˆÐØ	˜LÓ	(Øˆ
Ø  Ô1ˆDØ×Ñœm¨DÑ1Ö2ñ 2àÐð	 
)r   c                   ó$   • \ rS rSrSrS rS rSrg)r!   é­   a�  Retry handler.

The retry handler takes two params, ``checker`` object
and an ``action`` object.

The ``checker`` object must be a callable object and based on a response
and an attempt number, determines whether or not sufficient criteria for
a retry has been met.  If this is the case then the ``action`` object
(which also is a callable) determines what needs to happen in the event
of a retry.

c                 ó   • Xl         X l        g ©N)Ú_checkerÚ_action)Úselfr   r   s      r   Ú__init__ÚRetryHandler.__init__»   s   € ØŒØ�r   c                 óH  • UUUS.n[        U R                  [        5      (       a*  US   S   R                  S5      nUR	                  SU05        U R                  " S
0 UD6(       a'  U R                  US9n[        R                  SU5        U$ [        R                  S5        g	)zƒHandler for a retry.

Intended to be hooked up to an event handler (hence the **kwargs),
this will process retries appropriately.

)Úattempt_numberr>   Úcaught_exceptionÚrequest_dictÚcontextÚretriesÚretries_context)r   zRetry needed, action of: %szNo retry needed.N© )Ú
isinstancerU   r4   r.   ÚupdaterV   ÚloggerÚdebug)rW   r   r>   r\   ÚkwargsÚchecker_kwargsr`   Úresults           r   Ú__call__ÚRetryHandler.__call__¿   s–   € ð 'Ø Ø 0ñ
ˆô
 �d—m‘mÔ%9×:Ñ:Ø$ ^Ñ4°YÑ?×CÑCÀIÓNˆOØ×!Ñ!Ð#4°oÐ"FÔGà�=Š=Ñ*˜>×*Ø—\‘\¨8�\Ð4ˆFÜ�L‰LÐ6¸Ô?ØˆMÜ�‰Ð'Õ(r   )rV   rU   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rX   ri   Ú__static_attributes__ra   r   r   r!   r!   ­   s   † ñòõ)r   r!   c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚBaseCheckeréÖ   z”Base class for retry checkers.

Each class is responsible for checking a single criteria that determines
whether or not a retry should not happen.

c                 óh   • Ub  U R                  X5      $ Ub  U R                  X5      $ [        S5      e)ad  Determine if retry criteria matches.

Note that either ``response`` is not None and ``caught_exception`` is
None or ``response`` is None and ``caught_exception`` is not None.

:type attempt_number: int
:param attempt_number: The total number of times we've attempted
    to send the request.

:param response: The HTTP response (if one was received).

:type caught_exception: Exception
:param caught_exception: Any exception that was caught while trying to
    send the HTTP response.

:return: True, if the retry criteria matches (and therefore a retry
    should occur.  False if the criteria does not match.

z,Both response and caught_exception are None.)Ú_check_responseÚ_check_caught_exceptionr   )rW   r[   r>   r\   s       r   ri   ÚBaseChecker.__call__Þ   sE   € ð, ÑØ×'Ñ'¨ÓAÐAØÑ)Ø×/Ñ/Øóð ô ÐKÓLÐLr   c                 ó   • g rT   ra   ©rW   r[   r>   s      r   ru   ÚBaseChecker._check_responseý   ó   € Ør   c                 ó   • g rT   ra   ©rW   r[   r\   s      r   rv   Ú#BaseChecker._check_caught_exception   r{   r   ra   N)	rk   rl   rm   rn   ro   ri   ru   rv   rp   ra   r   r   rr   rr   Ö   s   † ñòMò>õr   rr   c                   ó.   • \ rS rSrSrSS jrS rS rSrg)	r4   i  a{  Allow retries up to a maximum number of attempts.

This will pass through calls to the decorated retry checker, provided
that the number of attempts does not exceed max_attempts.  It will
also catch any retryable_exceptions passed in.  Once max_attempts has
been exceeded, then False will be returned or the retryable_exceptions
that was previously being caught will be raised.

Nc                 ó(   • Xl         X l        X0l        g rT   ©rU   Ú_max_attemptsÚ_retryable_exceptions)rW   r   r,   r-   s       r   rX   ÚMaxAttemptsDecorator.__init__  s   € ØŒØ)ÔØ%9Õ"r   c                 ó  • U(       a)  [        UR                  SS5      U R                  5      US'   U R                  XU5      nU(       a?  XR                  :¼  a.  Ub  SUS   ;   a  SUS   S   S'   [        R                  SU5        gU$ g)	NÚmaxr   ÚResponseMetadatar   TÚMaxAttemptsReachedz0Reached the maximum number of retry attempts: %sF)r†   r.   r‚   Ú_should_retryrd   re   )rW   r[   r>   r\   r`   Úshould_retrys         r   ri   ÚMaxAttemptsDecorator.__call__  s£   € ö Ü%(Ø×#Ñ# E¨1Ó-¨t×/AÑ/Aó&ˆO˜EÑ"ð ×)Ñ)ØÐ&6ó
ˆö Ø×!3Ñ!3Ó3àÑ'Ð,>À(È1Á+Ó,Màð ˜Q‘KÐ 2Ñ3Ð4HÑIô —‘ØFØ"ôð à#Ð#àr   c                 óð   • U R                   (       a"  XR                  :  a   U R                  XU5      $ U R                  XU5      $ ! U R                    a  n[        R	                  SUSS9   S nAgS nAff = f)Nz,retry needed, retryable exception caught: %sT)Úexc_info)rƒ   r‚   rU   rd   re   )rW   r[   r>   r\   Úes        r   r‰   Ú"MaxAttemptsDecorator._should_retry0  s}   € Ø×%×%¨.×;MÑ;MÓ*Mð
Ø—}‘}Ø"Ð.>óð ð —=‘= Ð;KÓLÐLøð ×-Ñ-ó Ü—‘ØBØØ!ð ñ ô
 ûðús   ¢A ÁA5ÁA0Á0A5r�   rT   )	rk   rl   rm   rn   ro   rX   ri   r‰   rp   ra   r   r   r4   r4     s   † ñô:ò
õ8Mr   r4   c                   ó    • \ rS rSrS rS rSrg)rK   iC  c                 ó   • Xl         g rT   ©Ú_status_code)rW   rF   s     r   rX   ÚHTTPStatusCodeChecker.__init__D  s   € Ø'Õr   c                 ó€   • US   R                   U R                  :X  a!  [        R                  SU R                  5        gg)Nr   z5retry needed: retryable HTTP status code received: %sTF)rF   r“   rd   re   ry   s      r   ru   Ú%HTTPStatusCodeChecker._check_responseG  s:   € Ø�A‰;×"Ñ" d×&7Ñ&7Ó7Ü�L‰LØGØ×!Ñ!ôð àr   r’   N©rk   rl   rm   rn   rX   ru   rp   ra   r   r   rK   rK   C  s   † ò(õr   rK   c                   ó    • \ rS rSrS rS rSrg)rJ   iR  c                 ó   • Xl         X l        g rT   )r“   Ú_error_code)rW   rF   rG   s      r   rX   Ú ServiceErrorCodeChecker.__init__S  s   € Ø'ÔØ%Õr   c                 óü   • US   R                   U R                  :X  a_  US   R                  S0 5      R                  S5      nX0R                  :X  a,  [        R                  SU R                  U R                  5        gg)Nr   r   ÚErrorÚCodez>retry needed: matching HTTP status and error code seen: %s, %sTF)rF   r“   r.   rš   rd   re   )rW   r[   r>   Úactual_error_codes       r   ru   Ú'ServiceErrorCodeChecker._check_responseW  sq   € Ø�A‰;×"Ñ" d×&7Ñ&7Ó7Ø (¨¡§¡°¸Ó <× @Ñ @ÀÓ HÐØ ×$4Ñ$4Ó4Ü—‘ðà×%Ñ%Ø×$Ñ$ô	ð Ør   )rš   r“   Nr—   ra   r   r   rJ   rJ   R  s   † ò&õr   rJ   c                   ó    • \ rS rSrS rS rSrg)r5   ie  c                 ó   • Xl         g rT   ©Ú	_checkers)rW   r7   s     r   rX   ÚMultiChecker.__init__f  s   € Ø!�r   c                 óR   • U R                    H  nU" XU5      nU(       d  M  Us  $    g)NFr£   )rW   r[   r>   r\   r   Úchecker_responses         r   ri   ÚMultiChecker.__call__i  s4   € Ø—~”~ˆGÙ&ØÐ*:ó Ð÷  ÐØ'Ò'ñ &ð r   r£   N)rk   rl   rm   rn   rX   ri   rp   ra   r   r   r5   r5   e  s   † ò"õr   r5   c                   ó    • \ rS rSrS rS rSrg)rL   is  c                 ó   • Xl         g rT   ©Ú_header_name)rW   rI   s     r   rX   ÚCRC32Checker.__init__t  s   € à"Õr   c                 ó\  • US   nUR                   R                  U R                  5      nUc!  [        R	                  SU R                  5        g [        US   R                  5      S-  nU[        U5      :X  d4  [        R	                  S[        U5      U5        [        S[        U5      US9eg )Nr   z?crc32 check skipped, the %s header is not in the http response.l   ÿÿ z>retry needed: crc32 check failed, expected != actual: %s != %sr   )Úchecksum_typeÚexpected_checksumÚactual_checksum)	Úheadersr.   r¬   rd   re   r   ÚcontentÚintr   )rW   r[   r>   Úhttp_responseÚexpected_crcÚactual_crc32s         r   ru   ÚCRC32Checker._check_responsex  s­   € Ø  ™ˆØ$×,Ñ,×0Ñ0°×1BÑ1BÓCˆØÑÜ�L‰Lð(à×!Ñ!õô ! ¨!¡×!4Ñ!4Ó5¸
ÑBˆLØ¤3 |Ó#4Ó4Ü—‘ðä˜Ó%Ø ô	ô $Ø")Ü&)¨,Ó&7Ø$0ñð ð 5r   r«   Nr—   ra   r   r   rL   rL   s  s   † ò#õr   rL   c                   ó   • \ rS rSrSrS rSrg)rB   i‘  zXRaise any caught exceptions.

This class will raise any non None ``caught_exception``.

c                 ó   • UerT   ra   r}   s      r   rv   Ú'ExceptionRaiser._check_caught_exception˜  s
   € ð Ðr   ra   N)rk   rl   rm   rn   ro   rv   rp   ra   r   r   rB   rB   ‘  s   † ñõr   rB   rT   )r   Úloggingr   Úbinasciir   Úbotocore.exceptionsr   r   r   r   r   Ú	getLoggerrk   rd   rN   r   r   r#   r    r   r0   rA   r1   r!   rr   r4   rK   rJ   r5   rL   rB   ra   r   r   Ú<module>rÀ      sÖ   ðó Û Û Ý ÷õ ð 
×	Ò	˜8Ó	$€ð ØØØØð	!ð€òò.	ô8ô

ô
òD!òò$÷&)ñ &)÷R+ñ +ô\<M˜;ô <Mô~˜Kô ô˜kô ô&�;ô ô�;ô ô<�kõ r   