o ƚReQG @sddlZddlZddlZddlZddlZddlZddlmZm Z ddl m Z ddl m Z ddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%ddl&m'Z'ddl&m(Z(ddl&m)Z)ddl&m*Z*ddl&m+Z+dd l&m,Z,dd!l&m-Z-dd"l&m.Z.dd"l&m.Z/dd#l0m1Z1dd$l0m2Z2dd%l3m4Z4dd&l3m5Z5dd'l6m7Z7dd(l6m8Z8dZ9ej:rddl;Z;dd)l&md+ej?d,Z@e>d-ZAejBd.e@d/e@fd0d1ZejBd2ejCd3ejCd/ej?e@ge@ffd4d1Zd2ejCd3ejCd/ejDe@ej?e@ge@fffd5d1ZGd6d7d7eEZFeGZHGd8d9d9ZIGd:d;d;eJZKGdd?d?eLZMeGZNd@ejDejCeGfdAejCd/ejCfdBdCZOGdDdEdEeEZPGdFdGdGZQGdHdIdIeZRGdJdKdKeRZSGdLdMdMe jTZTGdNdOdOZUddPlVmWZWe9rddQlXmYZYdSdS)RN)ABCabstractmethod)futures)iscoroutinefunction) retry_base) retry_all) retry_always) retry_any)retry_if_exception)retry_if_exception_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_messagesleep)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) before_log)before_nothing) after_log) after_nothing)before_sleep_log)before_sleep_nothing) wait_base) stop_base WrappedFn)bound_RetValTfnreturncCdSN)r0r4r4/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/tenacity/__init__.pyretryar6dargsdkwcOr2r3r4r8r9r4r4r5r6fr7csBtdkrtdrtdSdtdtffdd }|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 rrfr1cst|trtd|jjd|jjdt|r!ti}ntr7t tj dr7tj |r7t i}nt i}||S)NzGot retry_base instance (zQ) as callable argument, this will probably hang indefinitely (did you mean retry=z(...)?)is_coroutine_function) isinstancerwarningswarn __class____name__r AsyncRetryingtornadohasattrgenr<TornadoRetryingRetryingwraps)r;rr:r4r5wrapvs   zretry..wrap)lencallabler6r-)r8r9rJr4r:r5r6ksc@seZdZdZdS)TryAgainz/Always retry the executed function when raised.N)rA __module__ __qualname____doc__r4r4r4r5rMsrMc@ eZdZdS) DoAttemptNrArNrOr4r4r4r5rRrRc@rQ)DoSleepNrSr4r4r4r5rUrTrUc@sReZdZUdZdZejeed<dZ ej eed<defddZ defd d Z dS) BaseActiona5Base 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 r4 REPR_FIELDSNNAMEr1cs.dfddjD}jjd|dS)Nz, c3s$|] }|dt|VqdS)=N)getattr).0fieldselfr4r5 s"z&BaseAction.__repr__..())joinrWr@rA)r^ state_strr4r]r5__repr__szBaseAction.__repr__cCst|Sr3)reprr]r4r4r5__str__szBaseAction.__str__) rArNrOrPrWtSequencestr__annotations__rXOptionalrdrfr4r4r4r5rVs rVc@s(eZdZdZdZdejddfddZdS) RetryActionrr6rr1NcCst||_dSr3)floatr)r^rr4r4r5__init__szRetryAction.__init__)rArNrOrWrXrg SupportsFloatrnr4r4r4r5rlsrlfirstsecondcCs|tur|S|Sr3)_unset)rprqr4r4r5 _first_setsrscs:eZdZdZd fdd Zdd d Zdefd d ZZS) RetryErrorz>Encapsulates the last attempt instance right before giving up. last_attemptFuturer1Ncs||_t|dSr3)rusuperrn)r^rur@r4r5rnszRetryError.__init__ t.NoReturncCs|jjr |j|r3)rufailedresultr]r4r4r5reraises zRetryError.reraisecCs|jjd|jdS)N[])r@rArur]r4r4r5rfzRetryError.__str__)rurvr1N)r1ry) rArNrOrPrnr|rirf __classcell__r4r4rxr5rts  rtc @s\eZdZdZdddZddd Zd ejeje d eje d ejd deje fddZ dS)AttemptManagerzManage attempt context. retry_stateRetryCallStatecCs ||_dSr3r)r^rr4r4r5rns zAttemptManager.__init__r1NcCr2r3r4r]r4r4r5 __enter__szAttemptManager.__enter__exc_type exc_value tracebacktypes.TracebackTypecCs0t|tr|j|||fdS|jddS)NT)r= BaseExceptionr set_exception set_result)r^rrrr4r4r5__exit__s  zAttemptManager.__exit__)rrr1N) rArNrOrPrnrrgrkTyperboolrr4r4r4r5rs  rc@sjeZdZeeeeeedde df de j e j e efgdfddddded e j d gdfd e j d gdfd e je j d gdfd ede je de je j d ge jffddZeeeeeeeeeef de j e j e j e efgdfefde j defde j defde j eefd e j e j d gdfefd e j e j d gdfefd e j e je j d gdfefd e j eefde j e je efde j e je j d ge jfefddfddZdefddZede jee jffddZdedefddZd)ddZdd de j e e!e jffdd Z"de j#e$ddffd!d"Z%e&d#e j d$e'fd%e jd&e jde'fd'd(Z(dS)* BaseRetryingNFrstopr,waitr+r6beforerafter before_sleepr|retry_error_clsretry_error_callbackc CsJ||_||_||_||_||_||_||_||_t |_ | |_ | |_ dSr3) rrrr6rrrr| threadinglocal_localrr r^rrrr6rrrr|rrr4r4r5rns   zBaseRetrying.__init__r1c Csn|jt||jt||jt||jt||jt||jt||jt||jt||j t| |j t| |j d S)z8Copy this object with some parameters changed if needed.) rrrr6rrrr|rr) r@rsrrrr6rrrr|rrrr4r4r5copys          zBaseRetrying.copycCsLd|jjdt|dd|jd|jd|jd|jd|jd |jd S) N) r@rAidrrrr6rrr]r4r4r5rdszBaseRetrying.__repr__cCs.z|jjWStyi|j_|jjYSw)aSReturn 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 statisticsAttributeErrorr]r4r4r5r"s    zBaseRetrying.statisticsr;cs\tdtjdtjdtjffdd }dtjdtjdtffdd }|_||_|S) z[Wrap a function for retrying. :param f: A function to wraps for retrying. argskwr1csg|Ri|Sr3r4)rrr;r^r4r5 wrapped_fDsz%BaseRetrying.wraps..wrapped_fkwargscsj|i|Sr3)rrH)rrrr4r5 retry_withHrz&BaseRetrying.wraps..retry_with) functoolsrHrgAnyr-r6r)r^r;rrr4rr5rH>s $ zBaseRetrying.wrapscCs0|jt|jd<d|jd<d|jd<dS)N start_timerattempt_numberridle_for)rcleartime monotonicr]r4r4r5beginPs  zBaseRetrying.beginrcCs&|j}|dur|jdur||tS|jjot|jt}|s,|j|ds,|S|j dur6| ||j |j d<|j |dr[|j rJ| |S||}|jrV||||jre|j|d}nd}t||_|j|7_|j d|7<|j dd7<|jdur||t|S)Nrdelay_since_first_attemptrrr)outcomerrRrzr= exceptionrMr6r{rseconds_since_startrrrrr|rrl next_actionrrrU)r^rfutis_explicit_retry retry_excrr4r4r5iterVs8            zBaseRetrying.iterccsd|t|ddid} |j|d}t|tr t|dVnt|tr/|||ndSq)Nr4)r0rrTr) rrrr=rRrrUprepare_for_next_attemptr)r^rdor4r4r5__iter__{s    zBaseRetrying.__iter__r0.rrcOr2r3r4)r^r0rrr4r4r5__call__r7zBaseRetrying.__call__r))rArNrOrrr"r r&r(rtrgCallableUnionintrmrrkrrrrnrrobjectrrirdpropertyDictrr-rHrrRrUr Generatorrrrr/rr4r4r4r5rs   "          %.rc@s8eZdZdZdejdefdejdejdefddZd S) rGzRetrying controller.r0.rrr1cOs|t||||d} |j|d}t|tr8z ||i|}Wnty1|tYnw| |nt|t rG| | |n|Sq )N) retry_objectr0rrTr) rrrr=rRrrsysexc_inforrUrr)r^r0rrrrr{r4r4r5rs       zRetrying.__call__N) rArNrOrPrgrr/rrr4r4r4r5rGs,rGc s\eZdZdZdeddffdd ZedefddZe ded e j d eddfd d Z Z S) rvzDEncapsulates a (future or past) attempted call to a target function.rr1Ncst||_dSr3)rwrnr)r^rrxr4r5rns  zFuture.__init__cCs |duS)z8Return whether a exception is being held in this future.N)rr]r4r4r5rzs z Future.failedvalue has_exceptioncCs(||}|r |||S|||S)zConstruct a new Future object.)rr)clsrrrrr4r4r5 constructs   zFuture.construct)rArNrOrPrrnrrrz classmethodrgrrrr4r4rxr5rvs&rvc @seZdZdZdedejedejdejddf dd Z e deje fd d Z dd d Z dejddfddZdejejeedfddfddZddZdS)rz5State related to a single call wrapped with Retrying.rr0rrr1NcCsDt|_||_||_||_||_d|_d|_d|_ d|_ d|_ dS)Nrr) rrrrr0rrrroutcome_timestamprr)r^rr0rrr4r4r5rns  zRetryCallState.__init__cCs|jdurdS|j|jSr3)rrr]r4r4r5rs  z"RetryCallState.seconds_since_startcCs$d|_d|_|jd7_d|_dSNr)rrrrr]r4r4r5rs z'RetryCallState.prepare_for_next_attemptvalcCs.t}t|j}|||||_|_dSr3)rrrvrrrr)r^rtsrr4r4r5rs  zRetryCallState.set_resultrrcCs2t}t|j}||d|||_|_dSr)rrrvrrrr)r^rrrr4r4r5rs zRetryCallState.set_exceptionc Cs|jdurd}n|jjr|j}d|jjd|d}nd|j}tt|jd}|jj}d|dt |d|j d |d |d S) Nznone yetzfailed ( raz returned rz : attempt #z ; slept for z; last result: >) rrzrr@rAr{rmroundrrr)r^r{rsleptclsnamer4r4r5rds  *zRetryCallState.__repr__r)rArNrOrPrrgrkr-rrnrrmrrrTuplerrrrdr4r4r4r5rs&  $ r)rB)rF)Zrrrrtypingrgr>abcrr concurrentrinspectrr6rrr r r r r rrrrrrnaprrrrrrrrrrrrrr r!r"r#r$wait_full_jitterrr%r&rr'r(rr)r*rC TYPE_CHECKINGtypesr+r,TypeVarrr-r/overloadrr ExceptionrMr NO_RESULTrRrmrUrVrlrrrsrtrrrGrvrpip._vendor.tenacity._asynciorBZpip._vendor.tenacity.tornadowebrFr4r4r4r5s                                         (0&- F