§
    7xÅjn9  ã                   óˆ  — 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dS )é    N)Úcrc32)ÚChecksumErrorÚConnectionClosedErrorÚConnectionErrorÚEndpointConnectionErrorÚReadTimeoutErrorÚGENERAL_CONNECTION_ERRORc                 ó€   — | 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       úFC:\Projects\Historical\venv\Lib\site-packages\botocore/retryhandler.pyÚdelay_exponentialr   +   s[   € ð ˆv‚~€~ÝŒ}‰ŒˆˆØ	�ŠˆÝØC¸TÐCÐ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                 óh   — 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   sK   € Ý.Ø˜~ðñ ô €Gõ -Ø˜~ðñ ô €Fõ  °Ð7Ñ7Ô7Ð7r   c                 ót   — | d         d         }|d         dk    rt          |d         |d         ¬¦  «        S d S )NÚ__default__ÚdelayÚtypeÚexponentialr   r   r   )r   )r"   r   Údelay_configs      r   r    r    X   sR   € ð
 ˜-Ô(¨Ô1€LØ�FÔ˜}Ò,Ð,Ý0Ø˜fÔ%Ø& Ô7ð
ñ 
ô 
ð 	
ð -Ð,r   c                 óÀ  — g }d }g }d| v r| d                               dg ¦  «        }| d         d         }|D ]R}||         }|                     t          |¦  «        ¦  «         t          |¦  «        }|�|                     |¦  «         ŒS|�||                       |¦  «        �g| |         d         }	|	D ]V}|                     t          |	|         ¦  «        ¦  «         t          |	|         ¦  «        }|�|                     |¦  «         ŒWt          |¦  «        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   sŠ  € Ø€HØ€LØÐØ˜ÐÐØ˜-Ô(×,Ò,¨Z¸Ñ<Ô<ˆØ˜mÔ,¨^Ô<ˆØð 	=ð 	=ˆCØ% cœ]ˆNØ�OŠOÕ2°>ÑBÔBÑCÔCÐCÝ:¸>ÑJÔJˆOØÐ*Ø$×+Ò+¨OÑ<Ô<Ð<øØÐ! f§j¢j°Ñ&@Ô&@Ð&LØ# NÔ3°JÔ?ÐØ%ð 	=ð 	=ˆCØ�OŠOÕ2Ð3EÀcÔ3JÑKÔKÑLÔLÐLÝ:Ø" 3Ô'ñô ˆOð Ð*Ø$×+Ò+¨OÑ<Ô<Ð<øÝ
ˆ8�}„}˜ÒÐå# H¨Q¤K¸lÐKÑKÔKÐKå$ XÑ.Ô.ˆÝ#ØØ%Ý!&Ð';Ñ!<Ô!<ð
ñ 
ô 
ð 	
r   c                 ó€   — d| d         v rt          | d         d         ¦  «        S d| d         v rt          ¦   «         S d S )NÚresponseÚapplies_whenÚsocket_errors)Ú_create_single_response_checkerÚExceptionRaiser)r"   s    r   r0   r0   ‡   sW   € Ø�V˜NÔ+Ð+Ð+Ý.Ø�>Ô" :Ô.ñ
ô 
ð 	
ð 
˜F >Ô2Ð	2Ð	2ÝÑ Ô Ð ð 
3Ð	2r   c                 óÔ   — d| v rt          | d         | d         ¬¦  «        }nEd| v rt          | d         ¬¦  «        }n*d| v rt          | d         ¬¦  «        }nt          d¦  «        ‚|S )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ð
ñ 
ô 
ˆˆð 
˜xÐ	'Ð	'Ý'Ø Ð!3Ô4ð
ñ 
ô 
ˆˆð 
˜Ð	 Ð	 Ý h¨{Ô&;Ð<Ñ<Ô<ˆˆõ Ð/Ñ0Ô0Ð0Ø€Nr   c                 ó¼   — | d         }d|                      di ¦  «        v rt          gS d|v r/g }|d         D ]"}|                     t          |         ¦  «         Œ#|S d S )Nr?   rH   r>   r@   )r.   r   r2   ÚEXCEPTION_MAP)r"   r?   Ú
exceptionsÚnames       r   r1   r1   ¢   s}   € Ø˜.Ô)€LØ�l×&Ò& z°2Ñ6Ô6Ð6Ð6ÝˆÐØ	˜LÐ	(Ð	(Øˆ
Ø  Ô1ð 	3ð 	3ˆDØ×Ò�m¨DÔ1Ñ2Ô2Ð2Ð2ØÐð	 
)Ð	(r   c                   ó   — e Zd ZdZd„ Zd„ ZdS )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                 ó"   — || _         || _        d S ©N)Ú_checkerÚ_action)Úselfr   r   s      r   Ú__init__zRetryHandler.__init__»   s   € ØˆŒØˆŒˆˆr   c                 ój  — |||dœ}t          | j        t          ¦  «        r8|d         d                              d¦  «        }|                     d|i¦  «          | j        d
i |¤Žr3|                      |¬¦  «        }t                               d|¦  «         |S t                               d¦  «         d	S )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Õ%9Ñ:Ô:ð 	HØ$ ^Ô4°YÔ?×CÒCÀIÑNÔNˆOØ×!Ò!Ð#4°oÐ"FÑGÔGÐGàˆ4Œ=Ð*Ð*˜>Ð*Ð*ð 	Ø—\’\¨8�\Ñ4Ô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dS )Ú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                 ó€   — |�|                       ||¦  «        S |�|                      ||¦  «        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.

        Nz,Both response and caught_exception are None.)Ú_check_responseÚ_check_caught_exceptionr   )rV   rY   r>   rZ   s       r   rg   zBaseChecker.__call__Þ   sU   € ð, ÐØ×'Ò'¨¸ÑAÔAÐAØÐ)Ø×/Ò/ØÐ 0ñô ð õ ÐKÑLÔLÐLr   c                 ó   — d S rS   r_   ©rV   rY   r>   s      r   ro   zBaseChecker._check_responseý   ó   € Øˆr   c                 ó   — d S 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   Ö   sN   € € € € € ðð ðMð Mð Mð>ð ð ðð ð ð ð r   rm   c                   ó&   — e Zd ZdZdd„Zd„ Zd„ ZdS )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                 ó0   — || _         || _        || _        d S rS   )rT   Ú_max_attemptsÚ_retryable_exceptions)rV   r   r,   r-   s       r   rW   zMaxAttemptsDecorator.__init__  s   € ØˆŒØ)ˆÔØ%9ˆÔ"Ð"Ð"r   c                 ó"  — |r,t          |                     dd¦  «        | j        ¦  «        |d<   |                      |||¦  «        }|rG|| j        k    r:|�d|d         v rd|d         d         d<   t                               d|¦  «         dS |S dS )	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ñ&ô &ˆO˜EÑ"ð ×)Ò)Ø˜HÐ&6ñ
ô 
ˆð ð 	Ø Ô!3Ò3Ð3àÐ'Ð,>À(È1Ä+Ð,MÐ,Màð ˜Q”KÐ 2Ô3Ð4HÑIõ —’ØFØ"ñô ð ð �uà#Ð#à�5r   c                 óî   — | j         rX|| j        k     rM	 |                      |||¦  «        S # | j         $ r(}t                               d|d¬¦  «         Y d }~dS d }~ww xY w|                      |||¦  «        S )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®   € ØÔ%ð 	M¨.¸4Ô;MÒ*MÐ*Mð
Ø—}’}Ø" HÐ.>ñô ð øð Ô-ð ð ð Ý—’ØBØØ!ð ñ ô ð ð
 �t�t�t�t�tøøøøðøøøð —=’= °Ð;KÑLÔLÐLs   ”+ «
AµAÁArS   )rh   ri   rj   rk   rW   rg   r~   r_   r   r   r4   r4     sU   € € € € € ðð ð:ð :ð :ð :ð
ð ð ð8Mð Mð Mð Mð Mr   r4   c                   ó   — e Zd Zd„ Zd„ ZdS )rK   c                 ó   — || _         d S rS   )Ú_status_code)rV   rF   s     r   rW   zHTTPStatusCodeChecker.__init__D  s   € Ø'ˆÔÐÐr   c                 óv   — |d         j         | j        k    r"t                               d| j        ¦  «         dS dS )Nr   z5retry needed: retryable HTTP status code received: %sTF)rF   r…   rb   rc   rr   s      r   ro   z%HTTPStatusCodeChecker._check_responseG  sB   € Ø�AŒ;Ô" dÔ&7Ò7Ð7Ý�LŠLØGØÔ!ñô ð ð �4à�5r   N©rh   ri   rj   rW   ro   r_   r   r   rK   rK   C  s2   € € € € € ð(ð (ð (ðð ð ð ð r   rK   c                   ó   — e Zd Zd„ Zd„ ZdS )rJ   c                 ó"   — || _         || _        d S rS   )r…   Ú_error_code)rV   rF   rG   s      r   rW   z ServiceErrorCodeChecker.__init__S  s   € Ø'ˆÔØ%ˆÔÐÐr   c                 óö   — |d         j         | j        k    rb|d                              di ¦  «                             d¦  «        }|| j        k    r(t                               d| j        | j        ¦  «         dS dS )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  s~   € Ø�AŒ;Ô" dÔ&7Ò7Ð7Ø (¨¤§¢°¸Ñ <Ô <× @Ò @ÀÑ HÔ HÐØ  DÔ$4Ò4Ð4Ý—’ðàÔ%ØÔ$ñ	ô ð ð �tØˆur   Nr‡   r_   r   r   rJ   rJ   R  s2   € € € € € ð&ð &ð &ðð ð ð ð r   rJ   c                   ó   — e Zd Zd„ Zd„ ZdS )r5   c                 ó   — || _         d S rS   ©Ú	_checkers)rV   r7   s     r   rW   zMultiChecker.__init__f  s   € Ø!ˆŒˆˆr   c                 ó@   — | j         D ]} ||||¦  «        }|r|c S ŒdS )NFr‘   )rV   rY   r>   rZ   r   Úchecker_responses         r   rg   zMultiChecker.__call__i  sM   € Ø”~ð 	(ð 	(ˆGØ&˜wØ Ð*:ñ ô  Ðð  ð (Ø'Ð'Ð'Ð'ð(àˆur   N)rh   ri   rj   rW   rg   r_   r   r   r5   r5   e  s2   € € € € € ð"ð "ð "ðð ð ð ð r   r5   c                   ó   — e Zd Zd„ Zd„ ZdS )rL   c                 ó   — || _         d S rS   )Ú_header_name)rV   rI   s     r   rW   zCRC32Checker.__init__t  s   € à"ˆÔÐÐr   c                 óŒ  — |d         }|j                              | j        ¦  «        }|€"t                               d| j        ¦  «         d S t          |d         j        ¦  «        dz  }|t          |¦  «        k    sHt                               dt          |¦  «        |¦  «         t          dt          |¦  «        |¬¦  «        ‚d S )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ÑCÔCˆØÐÝ�LŠLð(àÔ!ñô ð ð ð õ ! ¨!¤Ô!4Ñ5Ô5¸
ÑBˆLØ¥3 |Ñ#4Ô#4Ò4Ð4Ý—’ðå˜Ñ%Ô%Ø ñ	ô ð õ $Ø")Ý&)¨,Ñ&7Ô&7Ø$0ðñ ô ð ð 5Ð4r   Nr‡   r_   r   r   rL   rL   s  s2   € € € € € ð#ð #ð #ðð ð ð ð r   rL   c                   ó   — e Zd ZdZd„ ZdS )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ð 8ð 8ð 8ð

ð 

ð 

ð 

ð
ð 
ð 
ð 
ðD!ð !ð !ðð ð ð$ð ð ð&)ð &)ð &)ð &)ð &)ñ &)ô &)ð &)ðR+ð +ð +ð +ð +ñ +ô +ð +ð\<Mð <Mð <Mð <Mð <M˜;ñ <Mô <Mð <Mð~ð ð ð ð ˜Kñ ô ð ðð ð ð ð ˜kñ ô ð ð&ð ð ð ð �;ñ ô ð ðð ð ð ð �;ñ ô ð ð<ð ð ð ð �kñ ô ð ð ð r   