
    Dh                         d dl mZmZmZmZmZmZmZmZm	Z	m
Z
mZmZ ddlmZ ddZddZd Zd Z G d	 d
e      Z G d de      Z G d de      Z G d de      Zy)    )ChecksumErrorCRC32CheckerExceptionRaiserHTTPStatusCodeCheckerMaxAttemptsDecoratorMultiCheckerRetryHandlerServiceErrorCodeChecker_extract_retryable_exceptioncrc32create_retry_action_from_configlogger   )resolve_awaitableNc                 P    t        | |      }t        | |      }t        ||      S )N)operation_name)checkeraction) create_checker_from_retry_configr   AioRetryHandler)configr   r   r   s       z/var/www/fastuser/data/www/generator.snapmosaic.io/flask_app/venv/lib/python3.12/site-packages/aiobotocore/retryhandler.pycreate_retry_handlerr      s1    .~G -~F 76::    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 )N__default__policiesmax_attemptsr   r   )r   )r   retryable_exceptions)	getappend_create_single_checkerr   extendlenAioMaxAttemptsDecoratorAioMultiCheckertuple)r   r   checkersr   r   r   keycurrent_configretry_exceptionoperation_policiesmulti_checkers              r   r   r      sB   HL-(,,Z<m,^< 	=C%c]NOO2>BC:>JO*$++O<	= !fjj&@&L#N3J?% 	=COO23Ec3JKL:"3'O *$++O<	= 8}&x{NN'1&%!&';!<
 	
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_checkerr   )r   s    r   r"   r"   ?   sF    VN++.>":.
 	
 
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)r6   	crc32body)headerzUnknown retry policy)r
   r   AioCRC32Checker
ValueError)r/   r   s     r   r2   r2   H   s    x') !34 45
 N 
x	'' !34
 N 
	 !+)>? N /00r   c                       e Zd Zd Zd Zy)r   c                 h  K   |||d}t        | j                  t              r*|d   d   j                  d      }|j	                  d|i       t         | j                  d
i |       d{   r*| j                  |      }t        j                  d|       |S t        j                  d	       y7 Dw)zHandler 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_contextN)attemptszRetry needed, action of: %szNo retry needed. )	
isinstance_checkerr   r    updater   _actionr   debug)selfrD   r/   r?   kwargschecker_kwargsrC   results           r   _callzAioRetryHandler._call[   s      '  0

 dmm%9:$^4Y?CCINO!!#4o"FG"=4==#B>#BCCC\\8\4FLL6?M'(	 Ds   A)B2+B0,AB2c                 &     | j                   |i |S NrO   rK   argsrL   s      r   __call__zAioRetryHandler.__call__q       tzz4*6**r   N__name__
__module____qualname__rO   rU   rE   r   r   r   r   Z   s    ),+r   r   c                       e Zd Zd Zd Zd Zy)r%   c                   K   |r)t        |j                  dd      | j                        |d<   | j                  |||       d {   }|r<|| j                  k\  r+|d|d   v rd|d   d   d<   t	        j
                  d|       y|S y7 Cw)	Nmaxr   ResponseMetadatar   TMaxAttemptsReachedz0Reached the maximum number of retry attempts: %sF)r]   r    _max_attempts_should_retryr   rJ   )rK   r>   r/   r?   rC   should_retrys         r   rO   zAioMaxAttemptsDecorator._callv   s      %(##E1-t/A/A&OE" "//H&6
 
 !3!33',>(1+,M  QK 23, F" ##%
s   AB
BAB
c                 &     | j                   |i |S rQ   rR   rS   s      r   rU   z AioMaxAttemptsDecorator.__call__   rV   r   c                 B  K   | j                   r4|| j                  k  r%	 t        | j                  |||             d {   S t        | j                  |||             d {   S 7 (# | j                   $ r"}t	        j
                  d|d       Y d }~yd }~ww xY w7 :w)Nz,retry needed, retryable exception caught: %sT)exc_info)_retryable_exceptionsr`   r   rG   r   rJ   )rK   r>   r/   r?   es        r   ra   z%AioMaxAttemptsDecorator._should_retry   s     %%.4;M;M*M
.MM.(<LM   +nh8HI   -- B!
 sJ   BA) A'A)  B"B#B'A) )B8BBBBN)rX   rY   rZ   rO   rU   ra   rE   r   r   r%   r%   u   s    8+r   r%   c                       e Zd Zd Zd Zy)r&   c                 t   K   | j                   D ]#  }t         ||||             d {   }|s!|c S  y7 w)NF)	_checkersr   )rK   r>   r/   r?   r   checker_responses         r   rO   zAioMultiChecker._call   sK     ~~ 	(G%62BC&    ''	(  s   &8688c                 &     | j                   |i |S rQ   rR   rS   s      r   rU   zAioMultiChecker.__call__   rV   r   NrW   rE   r   r   r&   r&      s    +r   r&   c                       e Zd Zd Zd Zd Zy)r:   c                    K   || j                  ||       d {   S || j                  ||      S t        d      7 #w)Nz,Both response and caught_exception are None.)_check_response_check_caught_exceptionr;   )rK   r>   r/   r?   s       r   rO   zAioCRC32Checker._call   sU     --nhGGG)// 0  KLL Hs   A >$A c                 &     | j                   |i |S rQ   rR   rS   s      r   rU   zAioCRC32Checker.__call__   rV   r   c                 z  K   |d   }|j                   j                  | j                        }|!t        j                  d| j                         y t        |d   j                   d {         dz  }|t        |      k(  s7t        j                  dt        |      |       t        dt        |      |      y 7 Qw)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    _header_namer   rJ   r   contentintr   )rK   r>   r/   http_responseexpected_crcactual_crc32s         r   ro   zAioCRC32Checker._check_response   s      $,,001B1BCLL(!! !x{':':!:;jHL3|#44% 	 $")&),&7$0  5 ";s   A%B;'B9(AB;N)rX   rY   rZ   rO   rU   ro   rE   r   r   r:   r:      s    M+r   r:   rQ   )botocore.retryhandlerr   r   r   r   r   r   r	   r
   r   r   r   r   _helpersr   r   r   r"   r2   r   r%   r&   r:   rE   r   r   <module>r      se       (;
D!$+l +622 2j+l +$l $r   