"Jd#JddlZddlZddlZddlmZejrddlmZGddejZGddeZ Gdd e Z Gd d eZ Gd d eZ GddeZ GddeZGddeZGddeZdS)N)_utils)RetryCallStatecjeZdZdZejdddefdZd dZddde j d fd Z d S) wait_basez(Abstract base class for wait strategies. retry_staterreturncdSNselfrs L/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/tenacity/wait.py__call__zwait_base.__call__s other wait_combinec"t||Sr )rr rs r__add__zwait_base.__add__"sD%(((r)rrc<|dkr|S||SNr)rrs r__radd__zwait_base.__radd__%s" A::K||E"""rN)rrrr) __name__ __module__ __qualname____doc__abcabstractmethodfloatrrtypingUnionrr rrrrs22 $4     ))))#k#fl;V.W######rrc2eZdZdZdeddfdZdddefdZdS) wait_fixedzCWait strategy that waits a fixed amount of time between each retry.waitrNc||_dSr r#)r r$s r__init__zwait_fixed.__init__/s rrrc|jSr r&r s rrzwait_fixed.__call__2s r)rrrrrr'rr rrr#r#,s_MMUt$4rr#c$eZdZdZdfd ZxZS) wait_nonez7Wait strategy that doesn't wait at all before retrying.rNcJtddSr)superr')r __class__s rr'zwait_none.__init__9s! r)rN)rrrrr' __classcell__r-s@rr*r*6sCAArr*cleZdZdZd dejeefdejeefddfdZd d defd Z dS) wait_randomzAWait strategy that waits a random amount of time between min/max.rminmaxrNc"||_||_dSr )wait_random_minwait_random_max)r r3r4s rr'zwait_random.__init__@s""rrrcX|jtj|j|jz zzSr )r6randomr7r s rrzwait_random.__call__Ds'#v}$:NQUQe:e'fggr)rr2) rrrrr r!intrr'rr rrr1r1=sKK##FLe4#v|CQVJ?W#`d####h$4hhhhhhhrr1c2eZdZdZdeddfdZdddefdZdS) rz#Combine several waiting strategies. strategiesrNc||_dSr ) wait_funcsr r<s rr'zwait_combine.__init__K $rrrcDtfd|jDS)Nc30K|]}|VdS)rNr ).0xrs r z(wait_combine.__call__..Os0GG!11---GGGGGGr)sumr>r s `rrzwait_combine.__call__Ns(GGGGtGGGGGGrrrrrrr'rrr rrrrHsg--%I%$%%%%H$4HHHHHHHrrc2eZdZdZdeddfdZdddefdZdS) wait_chainaChain two or more waiting strategies. If all strategies are exhausted, the very last strategy is used thereafter. For example:: @retry(wait=wait_chain(*[wait_fixed(1) for i in range(3)] + [wait_fixed(2) for j in range(5)] + [wait_fixed(5) for k in range(4))) def wait_chained(): print("Wait 1s for 3 attempts, 2s for 5 attempts and 5s thereafter.") r<rNc||_dSr )r<r?s rr'zwait_chain.__init__br@rrrctt|jdt|j}|j|dz }||S)Nr2rC)r3r4attempt_numberlenr<)r r wait_func_no wait_funcs rrzwait_chain.__call__esL3{91==s4??S?STT OL1$45 y[1111rrHr rrrJrJRsc  %I%$%%%%2$42222222rrJc eZdZdZddejfdejee fdejee fdejee fddfd Z d d de fd Z dS) wait_incrementingzWait an incremental amount of time after each attempt. Starting at a starting value and incrementing by a value for each attempt (and restricting the upper limit to some maximum value). rdstart incrementr4rNc0||_||_||_dSr )rTrUr4)r rTrUr4s rr'zwait_incrementing.__init__rs  "rrrc||j|j|jdz zz}tdt ||jSNr2r)rTrUrMr4r3)r rresults rrzwait_incrementing.__call__|s9t~1Ka1OPQ1c&$(++,,,r rrrrrMAX_WAITr r!r:rr'rr rrrRrRks+,.1(. |CJ'<U +\#u* %   -$4-------rrRc eZdZdZdejddfdejee fdejee fdejee fdejee fd d f d Z d d d e fdZ d S)wait_exponentialaWait strategy that applies exponential backoff. It allows for a customized multiplier and an ability to restrict the upper and lower limits to some maximum and minimum value. The intervals are fixed (i.e. there is no jitter), so this strategy is suitable for balancing retries against latency when a required resource is unavailable for an unknown duration, but *not* suitable for resolving contention between multiple processes for a shared resource. Use wait_random_exponential for the latter case. r2r multiplierr4exp_baser3rNc>||_||_||_||_dSr )r_r3r4r`)r r_r4r`r3s rr'zwait_exponential.__init__s$%  rrrc |j|jdz z}|j|z}n#t$r |jcYSwxYwt t d|jt ||jSrX)r`rMr_ OverflowErrorr4r3)r rexprYs rrzwait_exponential.__call__sw -K$>$BCC_s*FF   8OOO 3q$(##S%:%:;;;s 33rZr rrr]r]s  01(.-.() ! !Le, !\#u* % !,sEz* ! \#u* % !  ! ! ! !<$4<<<<<<rms" '''''' 4333333########" hhhhh)hhhHHHHH9HHH222222222----- ---,<<<<