
     dG              
       V   d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZm	Z	 d dl
mZ d dlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl m"Z" ddl m#Z# ddl m$Z$ ddl m%Z% ddl m&Z& ddl'm(Z( ddl'm)Z) ddl'm*Z* ddl'm+Z+ dd l'm,Z, dd!l'm-Z- dd"l'm.Z. dd#l'm/Z/ dd#l'm/Z0 dd$l'm1Z1 dd%l2m3Z3 dd&l2m4Z4 dd'l5m6Z6 dd(l5m7Z7 dd)l8m9Z9 dd*l8m:Z: dZ;ej<        rd dl=Z=dd+l'm>Z> dd,l m?Z?  ej@        d-ejA        .          ZB ej@        d/          ZCejD        d0eBd1eBfd2            ZejD        d3ejE        d4ejE        d1ejA        eBgeBf         fd5            Zd3ejE        d4ejE        d1ejF        eBejA        eBgeBf         f         fd6Z G d7 d8eG          ZH eI            ZJ G d9 d:          ZK G d; d<eL          ZM G d= d>          ZN G d? d@eN          ZO eI            ZPdAejF        ejE        eIf         dBejE        d1ejE        fdCZQ G dD dEeG          ZR G dF dG          ZS G dH dIe          ZT G dJ dKeT          ZU G dL dMejV                  ZV G dN dO          ZWd dPlXmYZY e;rd dQlZm[Z[ dS dS )R    N)ABCabstractmethod)futures)iscoroutinefunction   )
retry_base)	retry_all)retry_always)	retry_any)retry_if_exception)retry_if_exception_type)retry_if_exception_cause_type)retry_if_not_exception_type)retry_if_not_result)retry_if_result)retry_never)retry_unless_exception_type)retry_if_exception_message)retry_if_not_exception_messagesleep)sleep_using_event)stop_after_attempt)stop_after_delay)stop_all)stop_any)
stop_never)stop_when_event_set)
wait_chain)wait_combine)wait_exponential)
wait_fixed)wait_incrementing)	wait_none)wait_random)wait_random_exponential)wait_exponential_jitter)
before_log)before_nothing)	after_log)after_nothing)before_sleep_log)before_sleep_nothing)	wait_base)	stop_base	WrappedFn)bound_RetValTfnreturnc                     d S N )r3   s    fC:\Users\ChattiNader\Documents\MyHotelMatch\api\dev\Lib\site-packages\pip/_vendor/tenacity/__init__.pyretryr9   c       D    dargsdkwc                      d S r6   r7   )r<   r=   s     r8   r9   r9   h   r:   r;   c                       t                     dk    r2t           d                   r t                       d                   S dt          dt          f fd}|S )zWrap a function with a new `Retrying` object.

    :param dargs: positional arguments passed to Retrying object
    :param dkw: keyword arguments passed to the Retrying object
    r   r   fr4   c                    t          | t                    r/t          j        d| j        j         d| j        j         d           t          |           rt          i }nYt          rFt          t          j
        d          r,t          j
                            |           rt          i }nt          i }|                    |           S )NzGot retry_base instance (zQ) as callable argument, this will probably hang indefinitely (did you mean retry=z(...)?)is_coroutine_function)
isinstancer   warningswarn	__class____name__r   AsyncRetryingtornadohasattrgenrB   TornadoRetryingRetryingwraps)r@   rr<   r=   s     r8   wrapzretry.<locals>.wrapx   s    !Z(( n0D n nPQP[Pdn n n   #1%% ,$15$@C$@$@ ,WW[2IJJ ,w{OpOpqrOsOs ,#U2c22e+s++771::r;   )lencallabler9   r0   )r<   r=   rP   s   `` r8   r9   r9   m   su     5zzQ8E!H--uwwuQx   	I 	) 	 	 	 	 	 	 	 r;   c                       e Zd ZdZdS )TryAgainz/Always retry the executed function when raised.N)rG   
__module____qualname____doc__r7   r;   r8   rT   rT      s        9999r;   rT   c                       e Zd ZdS )	DoAttemptNrG   rU   rV   r7   r;   r8   rY   rY              Dr;   rY   c                       e Zd ZdS )DoSleepNrZ   r7   r;   r8   r]   r]      r[   r;   r]   c                   t    e Zd ZU dZdZej        e         ed<   dZ	ej
        e         ed<   defdZdefdZdS )	
BaseActiona5  Base class for representing actions to take by retry object.

    Concrete implementations must define:
    - __init__: to initialize all necessary fields
    - REPR_FIELDS: class variable specifying attributes to include in repr(self)
    - NAME: for identification in retry object methods and callbacks
    r7   REPR_FIELDSNNAMEr4   c                 t     d                      fd j        D                       } j        j         d| dS )Nz, c              3   B   K   | ]}| d t          |          V  dS )=N)getattr).0fieldselfs     r8   	<genexpr>z&BaseAction.__repr__.<locals>.<genexpr>   s;      ``eAAu)=)=AA``````r;   ())joinr`   rF   rG   )rh   	state_strs   ` r8   __repr__zBaseAction.__repr__   sH    II````tO_`````	.)88I8888r;   c                      t          |           S r6   )reprrh   s    r8   __str__zBaseAction.__str__   s    Dzzr;   )rG   rU   rV   rW   r`   tSequencestr__annotations__ra   Optionalrn   rr   r7   r;   r8   r_   r_      s           $&KC%%% D!*S/   9# 9 9 9 9      r;   r_   c                   0    e Zd ZdZdZdej        ddfdZdS )RetryActionr   r9   r   r4   Nc                 .    t          |          | _        d S r6   )floatr   )rh   r   s     r8   __init__zRetryAction.__init__   s    5\\


r;   )rG   rU   rV   r`   ra   rs   SupportsFloatr|   r7   r;   r8   ry   ry      sB        KD"ao "$ " " " " " "r;   ry   firstsecondc                     | t           u r|n| S r6   )_unset)r~   r   s     r8   
_first_setr      s    f__66%/r;   c                   8     e Zd ZdZd
 fdZddZdefd	Z xZS )
RetryErrorz>Encapsulates the last attempt instance right before giving up.last_attemptFuturer4   Nc                 X    || _         t                                          |           d S r6   )r   superr|   )rh   r   rF   s     r8   r|   zRetryError.__init__   s)    (&&&&&r;   
t.NoReturnc                 P    | j         j        r| j                                         | r6   )r   failedresultrq   s    r8   reraisezRetryError.reraise   s*    # 	-#**,,,
r;   c                 0    | j         j         d| j         dS )N[])rF   rG   r   rq   s    r8   rr   zRetryError.__str__   s!    .)@@D,=@@@@r;   )r   r   r4   N)r4   r   )	rG   rU   rV   rW   r|   r   ru   rr   __classcell__rF   s   @r8   r   r      s{        HH' ' ' ' ' '   
A A A A A A A A Ar;   r   c            	           e Zd ZdZddZddZdej        ej        e	                  d	ej        e	         d
ej        d         dej        e
         fdZdS )AttemptManagerzManage attempt context.retry_stateRetryCallStatec                     || _         d S r6   r   )rh   r   s     r8   r|   zAttemptManager.__init__   s    &r;   r4   Nc                     d S r6   r7   rq   s    r8   	__enter__zAttemptManager.__enter__   s    r;   exc_type	exc_value	tracebacktypes.TracebackTypec                     t          |t                    r| j                            |||f           dS | j                            d            d S )NT)rC   BaseExceptionr   set_exception
set_result)rh   r   r   r   s       r8   __exit__zAttemptManager.__exit__   sW     i// 	**Hi+KLLL4 ''---4r;   )r   r   r4   N)rG   rU   rV   rW   r|   r   rs   rw   Typer   boolr   r7   r;   r8   r   r      s        !!' ' ' '   *QVM23 :m, :34	
 
D	     r;   r   c                      e Zd Zee e             e            eedde	df
de
j        e
j        eef         gdf         ddddded	e
j        d
gdf         de
j        d
gdf         de
j        e
j        d
gdf                  dede
j        e	         de
j        e
j        d
ge
j        f                  fdZeeeeeeeeeef
de
j        e
j        e
j        eef         gdf         ef         de
j        def         de
j        def         de
j        eef         d	e
j        e
j        d
gdf         ef         de
j        e
j        d
gdf         ef         de
j        e
j        e
j        d
gdf                  ef         de
j        eef         de
j        e
j        e	         ef         de
j        e
j        e
j        d
ge
j        f                  ef         dd fdZdefdZede
j        ee
j        f         fd            ZdedefdZd dZdd
de
j        e e!e
j        f         fdZ"de
j#        e$ddf         fdZ%e&de
j        de'f         de
j        de
j        de'fd            Z(dS )!BaseRetryingNFr   stopr/   waitr.   r9   beforer   afterbefore_sleepr   retry_error_clsretry_error_callbackc                     || _         || _        || _        || _        || _        || _        || _        || _        t          j	                    | _
        |	| _        |
| _        d S r6   )r   r   r   r9   r   r   r   r   	threadinglocal_localr   r   rh   r   r   r   r9   r   r   r   r   r   r   s              r8   r|   zBaseRetrying.__init__   sb     
		

(o''.$8!!!r;   r4   c                    |                      t          || j                  t          || j                  t          || j                  t          || j                  t          || j                  t          || j                  t          || j                  t          || j	                  t          |	| j
                  t          |
| j                  
  
        S )z8Copy this object with some parameters changed if needed.)
r   r   r   r9   r   r   r   r   r   r   )rF   r   r   r   r   r9   r   r   r   r   r   r   r   s              r8   copyzBaseRetrying.copy   s     ~~UDJ//D$),,D$),,UDJ//fdk22UDJ//#L$2CDDw55&8LMM!+,@$B[!\!\  
 
 	
r;   c                     d| j         j         dt          |           dd| j         d| j         d| j         d| j         d| j         d	| j         d
S )N<z object at 0xxz (stop=z, wait=z, sleep=z, retry=z	, before=z, after=z)>)	rF   rG   idr   r   r   r9   r   r   rq   s    r8   rn   zBaseRetrying.__repr__  s    $' $ $bhhD $ $I$ $I$ $ Z$ $ Z	$ $
 k$ $ Z$ $ $	
r;   c                 l    	 | j         j        S # t          $ r i | j         _        | j         j        cY S w xY w)aS  Return a dictionary of runtime statistics.

        This dictionary will be empty when the controller has never been
        ran. When it is running or has ran previously it should have (but
        may not) have useful and/or informational keys and values when
        running is underway and/or completed.

        .. warning:: The keys in this dictionary **should** be some what
                     stable (not changing), but there existence **may**
                     change between major releases as new statistics are
                     gathered or removed so before accessing keys ensure that
                     they actually exist and handle when they do not.

        .. note:: The values in this dictionary are local to the thread
                  running call (so if multiple threads share the same retrying
                  object - either directly or indirectly) they will each have
                  there own view of statistics they have collected (in the
                  future we may provide a way to aggregate the various
                  statistics from each thread).
        )r   
statisticsAttributeErrorrq   s    r8   r   zBaseRetrying.statistics$  sH    ,	*;)) 	* 	* 	*%'DK";))))	*s    "33r@   c                      t          j                  dt          j        dt          j        dt          j        f fd            }dt          j        dt          j        dt          f fd} |_        ||_        |S )z[Wrap a function for retrying.

        :param f: A function to wraps for retrying.
        argskwr4   c                       g| R i |S r6   r7   )r   r   r@   rh   s     r8   	wrapped_fz%BaseRetrying.wraps.<locals>.wrapped_fF  s#    4'D'''B'''r;   kwargsc                  D     j         | i |                              S r6   )r   rN   )r   r   r@   rh   s     r8   
retry_withz&BaseRetrying.wraps.<locals>.retry_withJ  s(    49d-f--33A666r;   )	functoolsrN   rs   Anyr0   r9   r   )rh   r@   r   r   s   ``  r8   rN   zBaseRetrying.wraps@  s     
			(QU 	(!% 	(AE 	( 	( 	( 	( 	( 	( 
		(	7ae 	7qu 	7 	7 	7 	7 	7 	7 	7 	7 	)	r;   c                     | j                                          t          j                    | j         d<   d| j         d<   d| j         d<   d S )N
start_timer   attempt_numberr   idle_for)r   cleartime	monotonicrq   s    r8   beginzBaseRetrying.beginR  sI    (,(8(8%,-()&'
###r;   r   c                    |j         }|*| j        |                     |           t                      S |j         j        o+t	          |j                                         t                    }|s*|                     |          s|                                S | j	        | 	                    |           |j
        | j        d<   |                     |          ra| j        r|                     |          S |                     |          }| j        r|                                ||                                | j        r|                     |          }nd}t#          |          |_        |xj        |z  c_        | j        dxx         |z  cc<   | j        dxx         dz  cc<   | j        |                     |           t+          |          S )Nr   delay_since_first_attempt        r   r   r   )outcomer   rY   r   rC   	exceptionrT   r9   r   r   seconds_since_startr   r   r   r   r   r   ry   next_actionr   r   r]   )rh   r   futis_explicit_retry	retry_excr   s         r8   iterzBaseRetrying.iterX  s   !;{&K(((;;'/6p:kFYFcFcFeFego;p;p! 	 TZZKZ%H%H 	 ::<<:!JJ{###7B7V34999-- 	1( >00===,,S11I| *'')))09 	II+I66EEE"-e"4"4%
###u,###()))Q.)))(k***u~~r;   c              #   V  K   |                                   t          | d di           }	 |                     |          }t          |t                    rt          |          V  nAt          |t                    r*|                                 |                     |           nd S )Nr7   )r3   r   r   Tr   )	r   r   r   rC   rY   r   r]   prepare_for_next_attemptr   )rh   r   dos      r8   __iter__zBaseRetrying.__iter__}  s      

$TdBGGG	{33B"i(( $=======B(( 44666

2	r;   r3   .r   r   c                     d S r6   r7   )rh   r3   r   r   s       r8   __call__zBaseRetrying.__call__  s    r;   r   ))rG   rU   rV   r   r   r$   r   r)   r+   r   rs   CallableUnionintr{   r   rw   r   r   r   r|   r   objectr   ru   rn   propertyDictr   r0   rN   r   rY   r]   r   	Generatorr   r   r   r2   r   r7   r;   r8   r   r      s        :?&%IKK33557E6CIM.8RV9 9z173:./569 9 	9
 9 
,-t349 z+,d239 j-=,>,D!EF9 9 
+9  j5E4F4M)NO9 9 9 96 KQ-3-3-3HNGMZ`)/?Eci
 
wqz173:#6"7"=>FG
 gk6)*
 gk6)*	

 wz6)*
 
$4#5t#;<fDE
 wqz#3"4d":;VCD
 gaj5E4F4L)MNPVVW
 v&
 
!3V!;<
  gaj=M<NPQPU<U1V&WY_&_`
 

 
 
 
6	
# 	
 	
 	
 	
 *AF3:. * * * X*6y Y    $( ( ( (# 0 #QWYQRQV=V5W # # # #J!+ndD&@A     1:c8m4 QU ae X`    ^  r;   r   c                   X    e Zd ZdZdej        def         dej        dej        defdZdS )	rM   zRetrying controller.r3   .r   r   r4   c                    |                                   t          | |||          }	 |                     |          }t          |t                    rU	  ||i |}|                    |           nw# t          $ r) |                    t          j	                               Y nEw xY wt          |t                    r*|                                 |                     |           n|S )N)retry_objectr3   r   r   Tr   )r   r   r   rC   rY   r   r   r   sysexc_infor]   r   r   )rh   r3   r   r   r   r   r   s          r8   r   zRetrying.__call__  s    

$$2DQWXXX	{33B"i(( 3R000F  **62222 % > > >--clnn=====> B(( 44666

2		s   A3 30B&%B&N)	rG   rU   rV   rW   rs   r   r2   r   r   r7   r;   r8   rM   rM     sZ        1:c8m4 QU ae X`      r;   rM   c            	       z     e Zd ZdZdeddf fdZedefd            Ze	dede
j        dedd fd	            Z xZS )
r   zDEncapsulates a (future or past) attempted call to a target function.r   r4   Nc                 V    t                                                       || _        d S r6   )r   r|   r   )rh   r   rF   s     r8   r|   zFuture.__init__  s'    ,r;   c                 .    |                                  duS )z8Return whether a exception is being held in this future.N)r   rq   s    r8   r   zFuture.failed  s     ~~t++r;   valuehas_exceptionc                 v     | |          }|r|                     |           n|                    |           |S )zConstruct a new Future object.)r   r   )clsr   r   r   r   s        r8   	constructzFuture.construct  sI     c.!! 	"e$$$$NN5!!!
r;   )rG   rU   rV   rW   r   r|   r   r   r   classmethodrs   r   r   r   r   s   @r8   r   r     s        NN-s -t - - - - - - , , , , X, s 15  RZ    [    r;   r   c            
           e Zd ZdZdedej        e         dej        dej        ddf
dZ	e
dej        e         fd	            Zdd
Zdej        ddfdZdej        ej        e         edf         ddfdZd ZdS )r   z5State related to a single call wrapped with Retrying.r   r3   r   r   r4   Nc                     t          j                    | _        || _        || _        || _        || _        d| _        d | _        d | _	        d| _
        d | _        d S )Nr   r   )r   r   r   r   r3   r   r   r   r   outcome_timestampr   r   )rh   r   r3   r   r   s        r8   r|   zRetryCallState.__init__  s^     .**(	 $%+/48"48r;   c                 2    | j         d S | j         | j        z
  S r6   )r   r   rq   s    r8   r   z"RetryCallState.seconds_since_start  s     !)4%77r;   c                 P    d | _         d | _        | xj        dz  c_        d | _        d S Nr   )r   r   r   r   rq   s    r8   r   z'RetryCallState.prepare_for_next_attempt  s3    !%q r;   valc                     t          j                    }t          | j                  }|                    |           ||c| _        | _        d S r6   )r   r   r   r   r   r   r   )rh   r   tsr   s       r8   r   zRetryCallState.set_result  sH    ^T())s/2B,d,,,r;   r   r   c                     t          j                    }t          | j                  }|                    |d                    ||c| _        | _        d S r   )r   r   r   r   r   r   r   )rh   r   r   r   s       r8   r   zRetryCallState.set_exception  sN    ^T())(1+&&&/2B,d,,,r;   c                 d   | j         d}nU| j         j        r-| j                                         }d|j        j         d| d}nd| j                                          }t          t          | j        d                    }| j        j        }d| dt          |            d| j
         d	| d
| dS )Nznone yetzfailed ( rk   z	returned    r   z: attempt #z; slept for z; last result: >)r   r   r   rF   rG   r   r{   roundr   r   r   )rh   r   r   sleptclsnames        r8   rn   zRetryCallState.__repr__  s    <FF\  	9..00IK	 3 <KKyKKKFF8!4!4!6!688FeDM1--...)r7rrRXXrr$2ErrSXrriorrrrr;   r   )rG   rU   rV   rW   r   rs   rw   r0   r   r|   r   r{   r   r   r   Tupler   r   r   rn   r7   r;   r8   r   r     s       ??9"9 Jy!9 e	9
 9 
9 9 9 9: 8QZ%6 8 8 8 X8
       7ae 7 7 7 7 77agaf].C]Ti.i&j 7os 7 7 7 7s s s s sr;   r   )rH   )rL   )\r   r   r   r   typingrs   rD   abcr   r   
concurrentr   inspectr   r9   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   napr   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   wait_full_jitterr'   r   r(   r)   r   r*   r+   r   r,   r-   rI   TYPE_CHECKINGtypesr.   r/   TypeVarr   r0   r2   overloadr   r   	ExceptionrT   r   	NO_RESULTrY   r{   r]   r_   ry   r   r   r   r   r   rM   r   r   pip._vendor.tenacity._asynciorH   pip._vendor.tenacity.tornadowebrL   r7   r;   r8   <module>r     s  &     



           # # # # # # # #       ' ' ' ' ' '                         % % % % % % * * * * * * 0 0 0 0 0 0 . . . . . . & & & & & & " " " " " "       . . . . . . - - - - - - 1 1 1 1 1 1       " " " " " " % $ $ $ $ $ " " " " " "                   % % % % % %             " " " " " "       # # # # # #             ) ) ) ) ) ) = = = = = = ) ) ) ) ) )       " " " " " "                   + * * * * * . . . . . . ?  LLL AIk444	19Z   	i 	I 	 	 	 	 	!% 	 	!*i[)5K*L 	 	 	 	!%  !')QZU^H^=_2_*`    :: : : : :y : : : FHH		 	 	 	 	 	 	 		 	 	 	 	e 	 	 	       (" " " " "* " " " 
0agaeVm, 0ae 0 0 0 0 0A A A A A A A A        0i i i i i3 i i iX    |   .    W^   .Cs Cs Cs Cs Cs Cs Cs CsL 8 7 7 7 7 7
 @????????@ @r;   