Ë
    £ªðin9  ã                   óZ  — d dl Z d dlZd dlZd dlmZ d dlmZmZmZm	Z	m
Z
  ej                  e«      Zdeee
e	giZd„ Zd„ Zdd„Zdd„Zdd	„Zd
„ Zd„ Zd„ Z G d„ d«      Z G d„ d«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)é    N)Úcrc32)ÚChecksumErrorÚConnectionClosedErrorÚConnectionErrorÚEndpointConnectionErrorÚReadTimeoutErrorÚGENERAL_CONNECTION_ERRORc                 óv   — | dk(  rt        j                   «       } n| dk  rt        d| › �«      ‚| ||dz
  z  z  }|S )a1  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       úl/var/www/acinvestment.org/public_html/aci/backend/venv/lib/python3.12/site-packages/botocore/retryhandler.pyÚdelay_exponentialr   +   sO   € ð ˆv‚~Ü�}‰}‹‰Ø	�ŠÜØ<¸T¸FÐCó
ð 	
ð ˜M¨h¸©lÑ;Ñ<€MØÐó    c                 ó:   — t        j                  t        | |¬«      S )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   € ô ×ÑÜ °Môð r   c                 óP   — t        | |¬«      }t        | |¬«      }t        ||¬«      S )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   s1   € Ü.Ø˜~ô€Gô -Ø˜~ô€Fô  °Ô7Ð7r   c                 óJ   — | d   d   }|d   dk(  rt        |d   |d   ¬«      S y )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                 ó  — g }d }g }d| v rb| d   j                  dg «      }| d   d   }|D ]@  }||   }|j                  t        |«      «       t        |«      }|€Œ0|j	                  |«       ŒB |�_| j                  |«      �N| |   d   }	|	D ]A  }|j                  t        |	|   «      «       t        |	|   «      }|€Œ1|j	                  |«       ŒC t        |«      dk(  rt        |d   |¬«      S t        |«      }
t        |
|t        |«      ¬«      S )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   sB  € Ø€HØ€LØÐØ˜ÑØ˜-Ñ(×,Ñ,¨Z¸Ó<ˆØ˜mÑ,¨^Ñ<ˆØò 	=ˆCØ% c™]ˆNØ�O‰OÔ2°>ÓBÔCÜ:¸>ÓJˆOØÑ*Ø$×+Ñ+¨OÕ<ð	=ð Ð! f§j¡j°Ó&@Ð&LØ# NÑ3°JÑ?ÐØ%ò 	=ˆCØ�O‰OÔ2Ð3EÀcÑ3JÓKÔLÜ:Ø" 3Ñ'óˆOð Ñ*Ø$×+Ñ+¨OÕ<ð	=ô ˆ8ƒ}˜Òä# H¨Q¡K¸lÔKÐKä$ XÓ.ˆÜ#ØØ%Ü!&Ð';Ó!<ô
ð 	
r   c                 óV   — d| d   v rt        | d   d   «      S d| d   v r
t        «       S y )NÚresponseÚapplies_whenÚsocket_errors)Ú_create_single_response_checkerÚExceptionRaiser)r"   s    r   r0   r0   ‡   sF   € Ø�V˜NÑ+Ñ+Ü.Ø�>Ñ" :Ñ.ó
ð 	
ð 
˜F >Ñ2Ñ	2ÜÓ Ð ð 
3r   c                 óž   — d| v rt        | d   | d   ¬«      }|S d| v rt        | d   ¬«      }|S d| v rt        | d   ¬«      }|S t        d«      ‚)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                 ó˜   — | d   }d|j                  di «      v rt        gS d|v r&g }|d   D ]  }|j                  t        |   «       Œ |S y )Nr?   rH   r>   r@   )r.   r   r2   ÚEXCEPTION_MAP)r"   r?   Ú
exceptionsÚnames       r   r1   r1   ¢   sh   € Ø˜.Ñ)€LØ�l×&Ñ& z°2Ó6Ñ6ÜˆÐØ	˜LÑ	(Øˆ
Ø  Ñ1ò 	3ˆDØ×Ñœm¨DÑ1Õ2ð	3àÐð	 
)r   c                   ó   — e Zd ZdZd„ Zd„ Zy)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                 ó    — || _         || _        y ©N)Ú_checkerÚ_action)Úselfr   r   s      r   Ú__init__zRetryHandler.__init__»   s   € ØˆŒØˆ�r   c                 ó:  — |||dœ}t        | j                  t        «      r*|d   d   j                  d«      }|j	                  d|i«        | j                  d
i |¤Žr*| j                  |¬«      }t        j                  d|«       |S t        j                  d«       y	)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© )Ú
isinstancerT   r4   r.   ÚupdaterU   ÚloggerÚdebug)rV   r   r>   rZ   ÚkwargsÚchecker_kwargsr^   Úresults           r   Ú__call__zRetryHandler.__call__¿   s•   € ð 'Ø Ø 0ñ
ˆô
 �d—m‘mÔ%9Ô:Ø$ ^Ñ4°YÑ?×CÑCÀIÓNˆOØ×!Ñ!Ð#4°oÐ"FÔGàˆ4�=‰=Ñ*˜>Ò*Ø—\‘\¨8�\Ó4ˆFÜ�L‰LÐ6¸Ô?ØˆMÜ�‰Ð'Õ(r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rW   rg   r_   r   r   r!   r!   ­   s   „ ñòó)r   r!   c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)ÚBaseCheckerz 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   — |�| j                  ||«      S |�| j                  ||«      S t        d«      ‚)aÄ  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   )rV   rY   r>   rZ   s       r   rg   zBaseChecker.__call__Þ   sJ   € ð, ÐØ×'Ñ'¨¸ÓAÐAØÐ)Ø×/Ñ/ØÐ 0óð ô ÐKÓLÐLr   c                  ó   — y rS   r_   ©rV   rY   r>   s      r   ro   zBaseChecker._check_responseý   ó   € Ør   c                  ó   — y rS   r_   ©rV   rY   rZ   s      r   rp   z#BaseChecker._check_caught_exception   rs   r   N)rh   ri   rj   rk   rg   ro   rp   r_   r   r   rm   rm   Ö   s   „ ñòMò>ór   rm   c                   ó$   — e Zd ZdZdd„Zd„ Zd„ Zy)r4   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                 ó.   — || _         || _        || _        y rS   )rT   Ú_max_attemptsÚ_retryable_exceptions)rV   r   r,   r-   s       r   rW   zMaxAttemptsDecorator.__init__  s   € ØˆŒØ)ˆÔØ%9ˆÕ"r   c                 óü   — |r)t        |j                  dd«      | j                  «      |d<   | j                  |||«      }|r<|| j                  k\  r+|�d|d   v rd|d   d   d<   t        j                  d|«       y|S y)	NÚmaxr   ÚResponseMetadatar   TÚMaxAttemptsReachedz0Reached the maximum number of retry attempts: %sF)r{   r.   rx   Ú_should_retryrb   rc   )rV   rY   r>   rZ   r^   Úshould_retrys         r   rg   zMaxAttemptsDecorator.__call__  s§   € ñ Ü%(Ø×#Ñ# E¨1Ó-¨t×/AÑ/Aó&ˆO˜EÑ"ð ×)Ñ)Ø˜HÐ&6ó
ˆñ Ø ×!3Ñ!3Ò3àÐ'Ð,>À(È1Á+Ñ,Màð ˜Q‘KÐ 2Ñ3Ð4HÑIô —‘ØFØ"ôð à#Ð#àr   c                 óî   — | j                   r#|| j                  k  r	 | j                  |||«      S | j                  |||«      S # | j                   $ r"}t        j	                  d|d¬«       Y d }~yd }~ww xY w)Nz,retry needed, retryable exception caught: %sT)Úexc_info)ry   rx   rT   rb   rc   )rV   rY   r>   rZ   Úes        r   r~   z"MaxAttemptsDecorator._should_retry0  sƒ   € Ø×%Ò%¨.¸4×;MÑ;MÒ*Mð
Ø—}‘}Ø" HÐ.>óð ð —=‘= °Ð;KÓLÐLøð ×-Ñ-ò Ü—‘ØBØØ!ð ô ô
 ûðús   �A ÁA4ÁA/Á/A4rS   )rh   ri   rj   rk   rW   rg   r~   r_   r   r   r4   r4     s   „ ñó:ò
ó8Mr   r4   c                   ó   — e Zd Zd„ Zd„ Zy)rK   c                 ó   — || _         y rS   )Ú_status_code)rV   rF   s     r   rW   zHTTPStatusCodeChecker.__init__D  s
   € Ø'ˆÕr   c                 ó~   — |d   j                   | j                  k(  r!t        j                  d| j                  «       yy)Nr   z5retry needed: retryable HTTP status code received: %sTF)rF   r…   rb   rc   rr   s      r   ro   z%HTTPStatusCodeChecker._check_responseG  s:   € Ø�A‰;×"Ñ" d×&7Ñ&7Ò7Ü�L‰LØGØ×!Ñ!ôð àr   N©rh   ri   rj   rW   ro   r_   r   r   rK   rK   C  s   „ ò(ór   rK   c                   ó   — e Zd Zd„ Zd„ Zy)rJ   c                 ó    — || _         || _        y rS   )r…   Ú_error_code)rV   rF   rG   s      r   rW   z ServiceErrorCodeChecker.__init__S  s   € Ø'ˆÔØ%ˆÕr   c                 óú   — |d   j                   | j                  k(  r_|d   j                  di «      j                  d«      }|| j                  k(  r,t        j                  d| j                  | j                  «       yy)Nr   r   ÚErrorÚCodez>retry needed: matching HTTP status and error code seen: %s, %sTF)rF   r…   r.   rŠ   rb   rc   )rV   rY   r>   Úactual_error_codes       r   ro   z'ServiceErrorCodeChecker._check_responseW  ss   € Ø�A‰;×"Ñ" d×&7Ñ&7Ò7Ø (¨¡§¡°¸Ó <× @Ñ @ÀÓ HÐØ  D×$4Ñ$4Ò4Ü—‘ðà×%Ñ%Ø×$Ñ$ô	ð Ør   Nr‡   r_   r   r   rJ   rJ   R  s   „ ò&ór   rJ   c                   ó   — e Zd Zd„ Zd„ Zy)r5   c                 ó   — || _         y rS   ©Ú	_checkers)rV   r7   s     r   rW   zMultiChecker.__init__f  s	   € Ø!ˆ�r   c                 óF   — | j                   D ]  } ||||«      }|sŒ|c S  y)NFr‘   )rV   rY   r>   rZ   r   Úchecker_responses         r   rg   zMultiChecker.__call__i  s8   € Ø—~‘~ò 	(ˆGÙ&Ø Ð*:ó Ðò  Ø'Ò'ð	(ð r   N)rh   ri   rj   rW   rg   r_   r   r   r5   r5   e  s   „ ò"ór   r5   c                   ó   — e Zd Zd„ Zd„ Zy)rL   c                 ó   — || _         y rS   )Ú_header_name)rV   rI   s     r   rW   zCRC32Checker.__init__t  s
   € à"ˆÕr   c                 ó^  — |d   }|j                   j                  | j                  «      }|€!t        j	                  d| j                  «       y t        |d   j                  «      dz  }|t        |«      k(  s7t        j	                  dt        |«      |«       t        dt        |«      |¬«      ‚y )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—   rb   rc   r   ÚcontentÚintr   )rV   rY   r>   Úhttp_responseÚexpected_crcÚactual_crc32s         r   ro   zCRC32Checker._check_responsex  s­   € Ø  ™ˆØ$×,Ñ,×0Ñ0°×1BÑ1BÓCˆØÐÜ�L‰Lð(à×!Ñ!õô ! ¨!¡×!4Ñ!4Ó5¸
ÑBˆLØ¤3 |Ó#4Ò4Ü—‘ðä˜Ó%Ø ô	ô $Ø")Ü&)¨,Ó&7Ø$0ôð ð 5r   Nr‡   r_   r   r   rL   rL   s  s   „ ò#ór   rL   c                   ó   — e Zd ZdZd„ Zy)rB   z`Raise any caught exceptions.

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

    c                 ó   — |‚rS   r_   ru   s      r   rp   z'ExceptionRaiser._check_caught_exception˜  s
   € ð Ðr   N)rh   ri   rj   rk   rp   r_   r   r   rB   rB   ‘  s   „ ñór   rB   rS   )r   Úloggingr   Úbinasciir   Úbotocore.exceptionsr   r   r   r   r   Ú	getLoggerrh   rb   rN   r   r   r#   r    r   r0   rA   r1   r!   rm   r4   rK   rJ   r5   rL   rB   r_   r   r   ú<module>r¨      sØ   ðó Û Û Ý ÷õ ð 
ˆ×	Ñ	˜8Ó	$€ð ØØØØð	!ð€òò.	ó8ó

ó
òD!òò$÷&)ñ &)÷R+ñ +ô\<M˜;ô <Mô~˜Kô ô˜kô ô&�;ô ô�;ô ô<�kõ r   