§
    9xÅj©l  ã                   ó0  — d 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
 ddlmZmZ ddlmZmZ dZddd	œZ ej        e¦  «        Zd)d
„Z G d„ d¦  «        Z G d„ d¦  «        Z G d„ 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 ¦  «        Z! G d!„ d"¦  «        Z" G d#„ d$e¦  «        Z# G d%„ d&e¦  «        Z$ G d'„ d(¦  «        Z%dS )*aC  Standard retry behavior.

This contains the default standard retry behavior.
It provides consistent behavior with other AWS SDKs.

The key base classes uses for retries:

    * ``BaseRetryableChecker`` - Use to check a specific condition that
    indicates a retry should happen.  This can include things like
    max attempts, HTTP status code checks, error code checks etc.
    * ``RetryBackoff`` - Use to determine how long we should backoff until
    we retry a request.  This is the class that will implement delay such
    as exponential backoff.
    * ``RetryPolicy`` - Main class that determines if a retry should
    happen.  It can combine data from a various BaseRetryableCheckers
    to make a final call as to whether or not a retry should happen.
    It then uses a ``BaseRetryBackoff`` to determine how long to delay.
    * ``RetryHandler`` - The bridge between botocore's event system
    used by endpoint.py to manage retries and the interfaces defined
    in this module.

This allows us to define an API that has minimal coupling to the event
based API used by botocore.

é    N)ÚNEW_RETRIES_ENABLED)ÚConnectionErrorÚConnectTimeoutErrorÚHTTPClientErrorÚReadTimeoutError)ÚquotaÚspecial)ÚBaseRetryableCheckerÚBaseRetryBackoffé   é   ©Údynamodbzdynamodb-streamsc           	      ó„  — | j         j        j        }|                     ¦   «         }t	          ¦   «         }t
          rÌ|€|t          v rt          |         }n	|€t          }| j         j         	                    d|› �t          |¦  «        j        d|› �¬¦  «         t          |¦  «        }t          t          j        ¦   «         |¦  «        }t!          t#          t%          |¬¦  «        t'          ||¬¦  «        ¬¦  «        |||¬¦  «        }nbt          t          j        ¦   «         ¦  «        }t!          t#          t%          |pt          ¬¦  «        t'          ¦   «         ¬¦  «        ||¬¦  «        }| j         j         	                    d	|› �|j        ¦  «         d
|› �}| j         j         	                    d|› �|j        |¬¦  «         |S )Nzrequest-created.zseed-max-attempts-)Ú	unique_id)Úmax_attempts)Úservice_nameÚthrottling_detector)Úretry_checkerÚretry_backoff)Úretry_policyÚretry_event_adapterÚretry_quotar   )r   r   r   zafter-call.zretry-config-zneeds-retry.)ÚmetaÚservice_modelÚ
service_idÚ	hyphenizeÚRetryEventAdapterr   Ú_SERVICE_MAX_ATTEMPTSÚDEFAULT_MAX_ATTEMPTSÚeventsÚregisterÚMaxAttemptsSeederÚseed_max_attemptsÚThrottlingErrorDetectorÚRetryQuotaCheckerr   Ú
RetryQuotaÚRetryHandlerÚRetryPolicyÚStandardRetryConditionsÚExponentialBackoffÚrelease_retry_quotaÚneeds_retry)	Úclientr   r   Úservice_event_namer   r   r   Úhandlerr   s	            úJC:\Projects\Historical\venv\Lib\site-packages\botocore/retries/standard.pyÚregister_retry_handlerr2   4   s&  € Ø”Ô*Ô5€JØ#×-Ò-Ñ/Ô/ÐÝ+Ñ-Ô-Ðåð 1
àÐ Ø"Õ&;Ð;Ð;å0Ð1CÔDˆLˆLØÐ!Ý/ˆLð 	ŒÔ×#Ò#Ø3Ð1Ð3Ð3Ý˜lÑ+Ô+Ô=Ø?Ð+=Ð?Ð?ð 	$ñ 	
ô 	
ð 	
õ
 6Ð6IÑJÔJÐÝ'ÝÔÑÔÐ 3ñ
ô 
ˆõ Ý$Ý5Ø!-ðñ ô õ 1Ø!3Ø(;ðñ ô ð	ñ ô ð !4Ø#Ø+ð
ñ 
ô 
ˆˆõ (­Ô(8Ñ(:Ô(:Ñ;Ô;ˆÝÝ$Ý5Ø!-Ð!EÕ1Eðñ ô õ 1Ñ2Ô2ð	ñ ô ð !4Ø#ð	
ñ 	
ô 	
ˆð „KÔ×ÒØ*Ð(Ð*Ð*¨KÔ,Kñô ð ð 5Ð 2Ð4Ð4€IØ
„KÔ×ÒØ+Ð)Ð+Ð+ØÔØð  ñ ô ð ð
 €Nó    c                   ó   — e Zd ZdZd„ Zd„ ZdS )r#   a  Adds the resolved max attempts to the retries context.

    The ``max`` value is otherwise only added to the retries context by
    ``MaxAttemptsChecker`` when a retry is evaluated, which means it's
    absent from the initial attempt's ``amz-sdk-request`` header.

    c                 ó   — || _         d S ©N©Ú_max_attempts©Úselfr   s     r1   Ú__init__zMaxAttemptsSeeder.__init__�   ó   € Ø)ˆÔÐÐr3   c                 óP   — |j                              di ¦  «        }| j        |d<   d S )NÚretriesÚmax)ÚcontextÚ
setdefaultr8   )r:   ÚrequestÚkwargsÚretries_contexts       r1   r$   z#MaxAttemptsSeeder.seed_max_attempts„   s,   € Ø!œ/×4Ò4°YÀÑCÔCˆØ!%Ô!3ˆ˜ÑÐÐr3   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r;   r$   © r3   r1   r#   r#   x   s<   € € € € € ðð ð*ð *ð *ð4ð 4ð 4ð 4ð 4r3   r#   c                   óH   — e Zd ZdZdhdhddhdœZdej        fd„Zd	„ Zd
„ Z	dS )r(   z™Bridge between botocore's event system and this module.

    This class is intended to be hooked to botocore's event system
    as an event handler.
    ÚReceiveMessageÚGetActivityTaskÚPollForActivityTaskÚPollForDecisionTask)ÚsqsÚsfnÚswfNc                 óL   — || _         || _        || _        || _        || _        d S r6   )Ú_retry_policyÚ_retry_event_adapterÚ_retry_quotaÚ_service_nameÚ_sleep)r:   r   r   r   r   Úsleeps         r1   r;   zRetryHandler.__init__™   s/   € ð *ˆÔØ$7ˆÔ!Ø'ˆÔØ)ˆÔØˆŒˆˆr3   c                 ó¢  — d} | j         j        di |¤Ž}| j                             |¦  «        rì| j                             |¦  «        r6| j                             |¦  «        }t                               d|¦  «         n¶t          rz|  
                    |¦  «        re| j                             |¦  «        }|                      |¦  «         t                               d¦  «         | j                              |¦  «         dS t                               d¦  «         nt                               d¦  «         | j                              |¦  «         |S )z.Connect as a handler to the needs-retry event.Nz1Retry needed, retrying request after delay of: %sz;Retry needed but retry quota reached, not retrying request.FzNot retrying request.rI   )rT   Úcreate_retry_contextrS   Úshould_retryrU   Úacquire_retry_quotaÚcompute_retry_delayÚloggerÚdebugr   Ú_is_long_polling_operationrW   Ú!adapt_retry_response_from_context)r:   rC   Úretry_delayr@   Úpolling_delays        r1   r-   zRetryHandler.needs_retry§   sp  € àˆØ@�$Ô+Ô@ÐJÐJÀ6ÐJÐJˆØÔ×*Ò*¨7Ñ3Ô3ð  	2ð Ô ×4Ò4°WÑ=Ô=ð Ø"Ô0×DÒDÀWÑMÔM�Ý—’ØGØñô ð ð õ
 'ð %Ø×6Ò6°wÑ?Ô?ð %Ø(,Ô(:×(NÒ(NØ#ñ)ô )˜ð Ÿš MÑ2Ô2Ð2ÝŸšð4ñô ð ð Ô1×SÒSØ#ñô ð ð  %˜uÝ—’ð,ñô ð ð õ
 �LŠLÐ0Ñ1Ô1Ð1ØÔ!×CÒCÀGÑLÔLÐLØÐr3   c                 ó„   — | j         �|j        €dS | j                             | j         ¦  «        }|d uo|j        j        |v S ©NF)rV   Úoperation_modelÚ_LONG_POLLING_OPERATIONSÚgetÚname)r:   r@   Ú
operationss      r1   r`   z'RetryHandler._is_long_polling_operationÏ   sS   € ð ÔÐ%¨Ô)@Ð)HØ�5ØÔ2×6Ò6°tÔ7IÑJÔJˆ
à˜dÐ"ð ;ØÔ'Ô,°
Ð:ð	
r3   )
rE   rF   rG   rH   rg   ÚtimerX   r;   r-   r`   rI   r3   r1   r(   r(   ‰   s   € € € € € ðð ð !Ð!Ø!Ð"Ø%Ð'<Ð=ð ð  Ðð ØŒjðð ð ð ð&ð &ð &ðP	
ð 	
ð 	
ð 	
ð 	
r3   r(   c                   ó   — e Zd ZdZd„ Zd„ ZdS )r   a{  Adapter to existing retry interface used in the endpoints layer.

    This existing interface for determining if a retry needs to happen
    is event based and used in ``botocore.endpoint``.  The interface has
    grown organically over the years and could use some cleanup.  This
    adapter converts that interface into the interface used by the
    new retry strategies.

    c           	      ó”   — |d         }|€d}d}n|\  }}t          |d         |d         |||d         |d         d         ¬¦  «        }|S )	z+Create context based on needs-retry kwargs.ÚresponseNÚattemptsÚ	operationÚcaught_exceptionÚrequest_dictr@   )Úattempt_numberrf   Úhttp_responseÚparsed_responserq   Úrequest_context)ÚRetryContext)r:   rC   rn   rt   ru   r@   s         r1   rZ   z&RetryEventAdapter.create_retry_contextæ   ss   € à˜*Ô%ˆØÐð
 !ˆMØ"ˆOˆOà-5Ñ*ˆM˜?õ Ø! *Ô-Ø" ;Ô/Ø'Ø+Ø#Ð$6Ô7Ø" >Ô2°9Ô=ð
ñ 
ô 
ˆð ˆr3   c                 óœ   — |                      ¦   «         }|j        �0|j                             di ¦  «                             |¦  «         dS dS )z/Modify response back to user back from context.NÚResponseMetadata)Úget_retry_metadataru   rA   Úupdate)r:   r@   Úmetadatas      r1   ra   z3RetryEventAdapter.adapt_retry_response_from_contextÿ   s_   € ð
 ×-Ò-Ñ/Ô/ˆØÔ"Ð.ØÔ#×.Ò.Ð/AÀ2ÑFÔF×MÒMØñô ð ð ð ð /Ð.r3   N)rE   rF   rG   rH   rZ   ra   rI   r3   r1   r   r   Û   s<   € € € € € ðð ðð ð ð2	ð 	ð 	ð 	ð 	r3   r   c                   ó6   — e Zd ZdZ	 	 	 	 	 dd„Zd„ Zd„ Zd„ ZdS )rw   a‘  Normalize a response that we use to check if a retry should occur.

    This class smoothes over the different types of responses we may get
    from a service including:

        * A modeled error response from the service that contains a service
          code and error message.
        * A raw HTTP response that doesn't contain service protocol specific
          error keys.
        * An exception received while attempting to retrieve a response.
          This could be a ConnectionError we receive from our HTTP layer which
          could represent that we weren't able to receive a response from
          the service.

    This class guarantees that at least one of the above attributes will be
    non None.

    This class is meant to provide a read-only view into the properties
    associated with a possible retryable response.  None of the properties
    are meant to be modified directly.

    Nc                 óp   — || _         || _        || _        || _        || _        |€i }|| _        i | _        d S r6   )rs   rf   ru   rt   rq   rv   Ú_retry_metadata)r:   rs   rf   ru   rt   rq   rv   s          r1   r;   zRetryContext.__init__&  sS   € ð -ˆÔØ.ˆÔð  /ˆÔà*ˆÔð !1ˆÔð
 Ð"Ø ˆOØ.ˆÔØ!ˆÔÐÐr3   c                 ó¢   — | j         €dS | j                              di ¦  «        }t          |t          ¦  «        sdS |                     d¦  «        S )z‡Check if there was a parsed response with an error code.

        If we could not find any error codes, ``None`` is returned.

        NÚErrorÚCode)ru   rh   Ú
isinstanceÚdict)r:   Úerrors     r1   Úget_error_codezRetryContext.get_error_codeE  sS   € ð ÔÐ'ØˆFØÔ$×(Ò(¨°"Ñ5Ô5ˆÝ˜%¥Ñ&Ô&ð 	ØˆFØ�yŠy˜Ñ Ô Ð r3   c                 ó*   —  | j         j        di |¤Ž dS )zúAdd key/value pairs to the retry metadata.

        This allows any objects during the retry process to add
        metadata about any checks/validations that happened.

        This gets added to the response metadata in the retry handler.

        NrI   )r   r{   )r:   rC   s     r1   Úadd_retry_metadatazRetryContext.add_retry_metadataR  s&   € ð 	$ˆÔÔ#Ð-Ð- fÐ-Ð-Ð-Ð-Ð-r3   c                 ó4   — | j                              ¦   «         S r6   )r   Úcopy©r:   s    r1   rz   zRetryContext.get_retry_metadata]  s   € ØÔ#×(Ò(Ñ*Ô*Ð*r3   )NNNNN)rE   rF   rG   rH   r;   r†   rˆ   rz   rI   r3   r1   rw   rw     sp   € € € € € ðð ð4 ØØØØð"ð "ð "ð "ð>!ð !ð !ð	.ð 	.ð 	.ð+ð +ð +ð +ð +r3   rw   c                   ó    — e Zd Zd„ Zd„ Zd„ ZdS )r)   c                 ó"   — || _         || _        d S r6   )Ú_retry_checkerÚ_retry_backoff)r:   r   r   s      r1   r;   zRetryPolicy.__init__b  s   € Ø+ˆÔØ+ˆÔÐÐr3   c                 ó6   — | j                              |¦  «        S r6   )rŽ   Úis_retryable©r:   r@   s     r1   r[   zRetryPolicy.should_retryf  ó   € ØÔ"×/Ò/°Ñ8Ô8Ð8r3   c                 ó6   — | j                              |¦  «        S r6   )r�   Údelay_amountr’   s     r1   r]   zRetryPolicy.compute_retry_delayi  r“   r3   N)rE   rF   rG   r;   r[   r]   rI   r3   r1   r)   r)   a  sA   € € € € € ð,ð ,ð ,ð9ð 9ð 9ð9ð 9ð 9ð 9ð 9r3   r)   c                   óf   — e Zd ZdZdZdZdZdddœZdd	idd	id
œZde	j	        ddfd„Z
d„ Zd„ Zd„ ZdS )r+   é   é   zx-amz-retry-afteré   é   gš™™™™™©?)Úthrottling_base_scaleÚnon_throttling_base_scalerœ   gš™™™™™™?r   Nc                 óV   — | j         | _        || _        || _        || _        || _        d S r6   )Ú_BASEÚ_baseÚ_max_backoffÚ_randomrV   Ú_throttling_detector)r:   Úmax_backoffÚrandomr   r   s        r1   r;   zExponentialBackoff.__init__}  s2   € ð ”ZˆŒ
Ø'ˆÔØˆŒØ)ˆÔØ$7ˆÔ!Ð!Ð!r3   c                 ó¢  — t           r�|                      ¦   «         t          |                      |¦  «        | j        |j        dz
  z  z  | j        ¦  «        z  }|                      |¦  «        }|�&t          |t          || j	        |z   ¦  «        ¦  «        S |S |                      ¦   «         t          | j        |j        dz
  z  | j        ¦  «        z  S )a  Calculates delay based on exponential backoff.

        This class implements truncated binary exponential backoff
        with jitter::

            t_i = rand(0, 1) * min(2 ** attempt, MAX_BACKOFF)

        where ``i`` is the request attempt (0 based).

        rš   )
r   r¡   ÚminÚ_get_base_scalerŸ   rs   r    Ú_get_retry_after_delayr?   Ú_RETRY_AFTER_MAX_ADDITIONAL)r:   r@   Út_iÚretry_afters       r1   r•   zExponentialBackoff.delay_amountŠ  sÝ   € õ ð 	Ø—,’,‘.”.¥3Ø×$Ò$ WÑ-Ô-Ø”: 'Ô"8¸1Ñ"<Ñ=ñ?àÔ!ñ$ô $ñ ˆCð ×5Ò5°gÑ>Ô>ˆKØÐ&åØÝ˜ TÔ%EÈÑ%KÑLÔLñô ð ð
 ˆJà—<’<‘>”>¥CØ” Ô 6¸Ñ :Ñ;ØÔ!ñ%ô %ñ ð r3   c                 óÄ   — | j         r'| j                              |¦  «        r| j        d         S | j        | j        v r| j        | j                 d         S | j        d         S )Nr›   rœ   )r¢   Ú is_throttling_error_from_contextÚ_DEFAULT_BACKOFF_CONFIGrV   Ú_SERVICE_BACKOFF_CONFIGr’   s     r1   r§   z"ExponentialBackoff._get_base_scale¯  s{   € àÔ%ð	IàÔ)×JÒJØñô ð	Ið Ô/Ð0GÔHÐHØÔ Ô!=Ð=Ð=ØÔ/°Ô0BÔCØ+ôð ð Ô+Ð,GÔHÐHr3   c                 ó:  — |j         €d S |j         j                             | j        ¦  «        }|€d S 	 t	          |¦  «        dz  }|dk     rt          d¦  «        ‚|S # t
          t          f$ r-}t                               d| j        ||¦  «         Y d }~d S d }~ww xY w)Ng     @�@r   zNegative retry-after valuez0Invalid %s header value: %s, ignoring. Error: %s)	rt   Úheadersrh   Ú_RETRY_AFTER_HEADERÚintÚ
ValueErrorÚOverflowErrorr^   r_   )r:   r@   Úretry_after_msÚvalueÚes        r1   r¨   z)ExponentialBackoff._get_retry_after_delay½  sÊ   € ØÔ Ð(Ø�4Ø Ô.Ô6×:Ò:ØÔ$ñ
ô 
ˆð Ð!Ø�4ð	Ý˜Ñ'Ô'¨&Ñ0ˆEØ�qŠyˆyÝ Ð!=Ñ>Ô>Ð>ØˆLøÝ�MÐ*ð 	ð 	ð 	Ý�LŠLØBØÔ(ØØñ	ô ð ð �4�4�4�4�4øøøøð	øøøs   ³(A ÁBÁ-"BÂB)rE   rF   rG   rž   Ú_MAX_BACKOFFr²   r©   r®   r¯   r¤   r;   r•   r§   r¨   rI   r3   r1   r+   r+   m  s³   € € € € € Ø€EØ€LØ-ÐØ"#Ðð "#Ø%)ðð Ðð 1°%Ð8Ø8¸%Ð@ðð Ðð ØŒ}ØØ ð8ð 8ð 8ð 8ð#ð #ð #ðJIð Ið Iðð ð ð ð r3   r+   c                   ó   — e Zd Zd„ Zd„ ZdS )ÚMaxAttemptsCheckerc                 ó   — || _         d S r6   r7   r9   s     r1   r;   zMaxAttemptsChecker.__init__Õ  r<   r3   c                 ó&  — |j         | j        k     }|j                             d¦  «        }|r,t	          |                     dd¦  «        | j        ¦  «        |d<   |s6t
                               d| j        ¦  «         |                     d¬¦  «         |S )Nr>   r?   r   zMax attempts of %s reached.T)ÚMaxAttemptsReached)rs   r8   rv   rh   r?   r^   r_   rˆ   )r:   r@   Úunder_max_attemptsrD   s       r1   r‘   zMaxAttemptsChecker.is_retryableØ  s�   € Ø$Ô3°dÔ6HÒHÐØ!Ô1×5Ò5°iÑ@Ô@ˆØð 	Ý%(Ø×#Ò# E¨1Ñ-Ô-¨tÔ/Añ&ô &ˆO˜EÑ"ð "ð 	@Ý�LŠLÐ6¸Ô8JÑKÔKÐKØ×&Ò&¸$Ð&Ñ?Ô?Ð?Ø!Ð!r3   N©rE   rF   rG   r;   r‘   rI   r3   r1   r»   r»   Ô  s2   € € € € € ð*ð *ð *ð
"ð 
"ð 
"ð 
"ð 
"r3   r»   c                   ó:   — e Zd Zg d¢Zg d¢ZeefZ	 	 	 dd„Zd„ Z	dS )ÚTransientRetryableChecker)ÚRequestTimeoutÚRequestTimeoutExceptionÚPriorRequestNotComplete)iô  iö  i÷  iø  Nc                 ó†   — |€| j         d d …         }|€| j        d d …         }|€| j        }|| _        || _        || _        d S r6   )Ú_TRANSIENT_ERROR_CODESÚ_TRANSIENT_STATUS_CODESÚ_TRANSIENT_EXCEPTION_CLSÚ_transient_error_codesÚ_transient_status_codesÚ_transient_exception_cls)r:   Útransient_error_codesÚtransient_status_codesÚtransient_exception_clss       r1   r;   z"TransientRetryableChecker.__init__ñ  sa   € ð !Ð(Ø$(Ô$?ÀÀÀÔ$BÐ!Ø!Ð)Ø%)Ô%AÀ!À!À!Ô%DÐ"Ø"Ð*Ø&*Ô&CÐ#Ø&;ˆÔ#Ø'=ˆÔ$Ø(?ˆÔ%Ð%Ð%r3   c                 óº   — |                      ¦   «         | j        v rdS |j        �|j        j        | j        v rdS |j        �t          |j        | j        ¦  «        S dS )NTF)r†   rÊ   rt   Ústatus_coderË   rq   rƒ   rÌ   r’   s     r1   r‘   z&TransientRetryableChecker.is_retryable  sw   € Ø×!Ò!Ñ#Ô# tÔ'BÐBÐBØ�4ØÔ Ð,àÔ%Ô1ØÔ/ð0ð 0ð �tØÔ#Ð/ÝØÔ(¨$Ô*Gñô ð ð ˆur3   )NNN)
rE   rF   rG   rÇ   rÈ   r   r   rÉ   r;   r‘   rI   r3   r1   rÂ   rÂ   å  st   € € € € € ðð ð Ðð
 3Ð2Ð2ÐàØð Ðð #Ø#Ø $ð	@ð @ð @ð @ð ð ð ð ð r3   rÂ   c                   ó$   — e Zd Zg d¢Zdd„Zd„ ZdS )ÚThrottledRetryableChecker)Ú
ThrottlingÚThrottlingExceptionÚThrottledExceptionÚRequestThrottledExceptionÚTooManyRequestsExceptionÚ&ProvisionedThroughputExceededExceptionÚTransactionInProgressExceptionÚRequestLimitExceededÚBandwidthLimitExceededÚLimitExceededExceptionÚRequestThrottledÚSlowDownrÅ   ÚEC2ThrottledExceptionNc                 ó6   — |€| j         d d …         }|| _        d S r6   )Ú_THROTTLED_ERROR_CODESÚ_throttled_error_codes)r:   Úthrottled_error_codess     r1   r;   z"ThrottledRetryableChecker.__init__%  s(   € Ø Ð(Ø$(Ô$?ÀÀÀÔ$BÐ!Ø&;ˆÔ#Ð#Ð#r3   c                 ó8   — |                      ¦   «         | j        v S r6   )r†   rã   r’   s     r1   r‘   z&ThrottledRetryableChecker.is_retryable*  s   € ð ×%Ò%Ñ'Ô'¨4Ô+FÐFÐFr3   r6   )rE   rF   rG   râ   r;   r‘   rI   r3   r1   rÓ   rÓ     sN   € € € € € ðð ð Ðð"<ð <ð <ð <ð
Gð Gð Gð Gð Gr3   rÓ   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚModeledRetryableCheckerz0Check if an error has been modeled as retryable.c                 ó,   — t          ¦   «         | _        d S r6   )ÚModeledRetryErrorDetectorÚ_error_detectorr‹   s    r1   r;   z ModeledRetryableChecker.__init__3  s   € Ý8Ñ:Ô:ˆÔÐÐr3   c                 ój   — |                      ¦   «         }|€dS | j                             |¦  «        d uS re   )r†   rê   Údetect_error_type)r:   r@   Ú
error_codes      r1   r‘   z$ModeledRetryableChecker.is_retryable6  s:   € Ø×+Ò+Ñ-Ô-ˆ
ØÐØ�5ØÔ#×5Ò5°gÑ>Ô>ÀdÐJÐJr3   N)rE   rF   rG   rH   r;   r‘   rI   r3   r1   rç   rç   0  s=   € € € € € Ø:Ð:ð;ð ;ð ;ðKð Kð Kð Kð Kr3   rç   c                   ó    — e Zd ZdZdZdZd„ ZdS )ré   z<Checks whether or not an error is a modeled retryable error.ÚTRANSIENT_ERRORÚTHROTTLING_ERRORc                 ót  — |                      ¦   «         }|j        }|�|j        sdS |j        D ]‰}|j                             d¦  «        �m|j                             di ¦  «                             d¦  «        p|j        }||k    r2|j        d                              d¦  «        r	| j        c S | j        c S ŒŠdS )aC  Detect the error type associated with an error code and model.

        This will either return:

            * ``self.TRANSIENT_ERROR`` - If the error is a transient error
            * ``self.THROTTLING_ERROR`` - If the error is a throttling error
            * ``None`` - If the error is neither type of error.

        NÚ	retryabler…   ÚcodeÚ
throttling)r†   rf   Úerror_shapesr|   rh   ri   rð   rï   )r:   r@   rí   Úop_modelÚshapeÚerror_code_to_checks         r1   rì   z+ModeledRetryErrorDetector.detect_error_typeG  sÝ   € ð ×+Ò+Ñ-Ô-ˆ
ØÔ*ˆØÐ 8Ô#8ÐØˆFØÔ*ð 
	0ð 
	0ˆEØŒ~×!Ò! +Ñ.Ô.Ð:ð ”N×&Ò& w°Ñ3Ô3×7Ò7¸Ñ?Ô?ÐMÀ5Ä:ð $ð Ð!4Ò4Ð4Ø”~ kÔ2×6Ò6°|ÑDÔDð 5Ø#Ô4Ð4Ð4Ð4ØÔ/Ð/Ð/Ð/øð
	0ð 
	0r3   N)rE   rF   rG   rH   rï   rð   rì   rI   r3   r1   ré   ré   =  s6   € € € € € ØFÐFð (€OØ)Ðð
0ð 0ð 0ð 0ð 0r3   ré   c                   ó    — e Zd Zd„ Zd„ Zd„ ZdS )r%   c                 ó`   — t          ¦   «         | _        t          ¦   «         | _        || _        d S r6   )ré   Ú_modeled_error_detectorrÓ   Ú_fixed_error_code_detectorrT   )r:   r   s     r1   r;   z ThrottlingErrorDetector.__init__c  s,   € Ý'@Ñ'BÔ'BˆÔ$Ý*CÑ*EÔ*EˆÔ'Ø$7ˆÔ!Ð!Ð!r3   c                 óP   —  | j         j        di |¤Ž}|                      |¦  «        S )NrI   )rT   rZ   r­   )r:   rC   r@   s      r1   Úis_throttling_errorz+ThrottlingErrorDetector.is_throttling_errori  s1   € Ø@�$Ô+Ô@ÐJÐJÀ6ÐJÐJˆØ×4Ò4°WÑ=Ô=Ð=r3   c                 óŽ   — | j                              |¦  «        rdS | j                             |¦  «        }|| j        j        k    S )NT)rü   r‘   rû   rì   rð   )r:   r@   Ú
error_types      r1   r­   z8ThrottlingErrorDetector.is_throttling_error_from_contextm  sG   € ØÔ*×7Ò7¸Ñ@Ô@ð 	Ø�4ØÔ1×CÒCÀGÑLÔLˆ
Ø˜TÔ9ÔJÒJÐJr3   N)rE   rF   rG   r;   rþ   r­   rI   r3   r1   r%   r%   b  sF   € € € € € ð8ð 8ð 8ð>ð >ð >ðKð Kð Kð Kð Kr3   r%   c                   ó"   — e Zd ZdZefd„Zd„ ZdS )r*   z¡Concrete class that implements the standard retry policy checks.

    Specifically:

        not max_attempts and (transient or throttled or modeled_retry)

    c           
      ó  — t          |¦  «        | _        t          t          ¦   «         t	          ¦   «         t          ¦   «         t          t          j        ¦   «         t          j        ¦   «         g¦  «        g¦  «        | _	        d S r6   )
r»   Ú_max_attempts_checkerÚOrRetryCheckerrÂ   rÓ   rç   r	   ÚRetryIDPCommunicationErrorÚRetryDDBChecksumErrorÚ_additional_checkersr9   s     r1   r;   z StandardRetryConditions.__init__}  sv   € õ &8¸Ñ%EÔ%EˆÔ"Ý$2å)Ñ+Ô+Ý)Ñ+Ô+Ý'Ñ)Ô)ÝåÔ:Ñ<Ô<ÝÔ5Ñ7Ô7ðñô ð	
ñ%
ô %
ˆÔ!Ð!Ð!r3   c                 ój   — | j                              |¦  «        o| j                             |¦  «        S r6   )r  r‘   r  r’   s     r1   r‘   z$StandardRetryConditions.is_retryable�  s9   € ØÔ)×6Ò6Øñ
ô 
ð >àÔ'×4Ò4°WÑ=Ô=ð	>r3   N)rE   rF   rG   rH   r    r;   r‘   rI   r3   r1   r*   r*   t  sF   € € € € € ðð ð %9ð 
ð 
ð 
ð 
ð$>ð >ð >ð >ð >r3   r*   c                   ó   — e Zd Zd„ Zd„ ZdS )r  c                 ó   — || _         d S r6   )Ú	_checkers)r:   Úcheckerss     r1   r;   zOrRetryChecker.__init__–  s   € Ø!ˆŒˆˆr3   c                 óD   ‡— t          ˆfd„| j        D ¦   «         ¦  «        S )Nc              3   óB   •K  — | ]}|                      ‰¦  «        V — Œd S r6   )r‘   )Ú.0Úcheckerr@   s     €r1   ú	<genexpr>z.OrRetryChecker.is_retryable.<locals>.<genexpr>š  s1   øè è € ÐOÐO°W�7×'Ò'¨Ñ0Ô0ÐOÐOÐOÐOÐOÐOr3   )Úanyr  r’   s    `r1   r‘   zOrRetryChecker.is_retryable™  s(   ø€ ÝÐOÐOÐOÐOÀÄÐOÑOÔOÑOÔOÐOr3   NrÀ   rI   r3   r1   r  r  •  s7   € € € € € ð"ð "ð "ðPð Pð Pð Pð Pr3   r  c                   óJ   — e Zd ZdZdZdZdZdZee	fZ
dd„Zd„ Zd„ Zd	„ Zd
„ ZdS )r&   r™   é   rš   é
   Nc                 ó0   — || _         || _        d | _        d S r6   )Ú_quotar¢   Ú_last_amount_acquired)r:   r   r   s      r1   r;   zRetryQuotaChecker.__init__«  s   € ØˆŒØ$7ˆÔ!à%)ˆÔ"Ð"Ð"r3   c                 ó"  — t           r%|                      |¦  «        r| j        }n,| j        }n$|                      |¦  «        r| j        }n| j        }| j                             |¦  «        }|r||j	        d<   dS | 
                    d¬¦  «         dS )NÚretry_quota_capacityT)ÚRetryQuotaReachedF)r   Ú_is_throttling_errorÚ_THROTTLING_RETRY_COSTÚ_RETRY_COST_V2Ú_is_timeout_errorÚ_TIMEOUT_RETRY_REQUESTÚ_RETRY_COSTr  Úacquirerv   rˆ   )r:   r@   Úcapacity_amountÚsuccesss       r1   r\   z%RetryQuotaChecker.acquire_retry_quota±  s«   € Ýð 		3Ø×(Ò(¨Ñ1Ô1ð 6Ø"&Ô"=��à"&Ô"5��à×%Ò% gÑ.Ô.ð 3Ø"&Ô"=��à"&Ô"2�Ø”+×%Ò% oÑ6Ô6ˆØð 	ð ?NˆGÔ#Ð$:Ñ;Ø�4Ø×"Ò"°TÐ"Ñ:Ô:Ð:Øˆur3   c                 óH   — | j         €dS | j                              |¦  «        S re   )r¢   r­   r’   s     r1   r  z&RetryQuotaChecker._is_throttling_errorÆ  s.   € ØÔ$Ð,Ø�5ØÔ(×IÒIØñ
ô 
ð 	
r3   c                 ó6   — t          |j        | j        ¦  «        S r6   )rƒ   rq   Ú_TIMEOUT_EXCEPTIONSr’   s     r1   r  z#RetryQuotaChecker._is_timeout_errorÍ  s   € Ý˜'Ô2°DÔ4LÑMÔMÐMr3   c                 óÐ   — |€d S |j         }d|cxk    rdk     rMn d S d|vr!| j                             | j        ¦  «         d S |d         }| j                             |¦  «         d S d S )NéÈ   i,  r  )rÑ   r  ÚreleaseÚ_NO_RETRY_INCREMENT)r:   r@   rt   rC   rÑ   r#  s         r1   r,   z%RetryQuotaChecker.release_retry_quotaÑ  s•   € ð Ð ØˆFØ#Ô/ˆØ�+Ð#Ð#Ò#Ð# Ò#Ð#Ð#Ð#Ð#Ð#Ø%¨WÐ4Ð4Ø”×#Ò# DÔ$<Ñ=Ô=Ð=Ð=Ð=à")Ð*@Ô"A�Ø”×#Ò# OÑ4Ô4Ð4Ð4Ð4ð $Ð#r3   r6   )rE   rF   rG   r!  r  r+  r  r   r   r   r'  r;   r\   r  r  r,   rI   r3   r1   r&   r&   �  s�   € € € € € Ø€KØ€NØÐØÐØÐØ.Ð0@ÐAÐð*ð *ð *ð *ðð ð ð*
ð 
ð 
ðNð Nð Nð5ð 5ð 5ð 5ð 5r3   r&   r6   )&rH   Úloggingr¤   rk   Úbotocore.configproviderr   Úbotocore.exceptionsr   r   r   r   Úbotocore.retriesr   r	   Úbotocore.retries.baser
   r   r    r   Ú	getLoggerrE   r^   r2   r#   r(   r   rw   r)   r+   r»   rÂ   rÓ   rç   ré   r%   r*   r  r&   rI   r3   r1   ú<module>r2     s´  ððð ð4 €€€Ø €€€Ø €€€ð
 8Ð 7Ð 7Ð 7Ð 7Ð 7ðð ð ð ð ð ð ð ð ð ð ð ð ,Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ø HÐ HÐ HÐ HÐ HÐ HÐ HÐ HàÐ àØðð Ð ð 
ˆÔ	˜8Ñ	$Ô	$€ðAð Að Að AðH4ð 4ð 4ð 4ð 4ñ 4ô 4ð 4ð"O
ð O
ð O
ð O
ð O
ñ O
ô O
ð O
ðd-ð -ð -ð -ð -ñ -ô -ð -ðfP+ð P+ð P+ð P+ð P+ñ P+ô P+ð P+ðf	9ð 	9ð 	9ð 	9ð 	9ñ 	9ô 	9ð 	9ðdð dð dð dð dÐ)ñ dô dð dðN"ð "ð "ð "ð "Ð-ñ "ô "ð "ð")ð )ð )ð )ð )Ð 4ñ )ô )ð )ðXGð Gð Gð Gð GÐ 4ñ Gô Gð Gð>
Kð 
Kð 
Kð 
Kð 
KÐ2ñ 
Kô 
Kð 
Kð"0ð "0ð "0ð "0ð "0ñ "0ô "0ð "0ðJKð Kð Kð Kð Kñ Kô Kð Kð$>ð >ð >ð >ð >Ð2ñ >ô >ð >ðBPð Pð Pð Pð PÐ)ñ Pô Pð PðE5ð E5ð E5ð E5ð E5ñ E5ô E5ð E5ð E5ð E5r3   