U ʗ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:r4ddl;Z;dd)l&md+ej?d,Z@e>d-ZAejBe@e@d.d/d0ZejBejCejCej?e@ge@fd1d2d0ZejCejCejDe@ej?e@ge@ffd1d3d0ZGd4d5d5eEZFeGZHGd6d7d7ZIGd8d9d9eJZKGd:d;d;ZLGdd?d@ZOGdAdBdBeEZPGdCdDdDZQGdEdFdFeZRGdGdHdHeRZSGdIdJdJe jTZTGdKdLdLZUddMlVmWZWe9rddNlXmYZYdS)ON)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_RetValT)fnreturncCsdSN)r0r3r3/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/tenacity/__init__.pyretryasr5)dargsdkwr1cOsdSr2r3r6r7r3r3r4r5fscsDtdkr&tdr&tdSttdfdd }|SdS)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 rrfr1cszt|tr*td|jjd|jjdt|r>t}n2trft tj drftj |rft }n t }||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:rr8r3r4wrapvs    zretry..wrapN)lencallabler5r-)r6r7rIr3r8r4r5ksc@seZdZdZdS)TryAgainz/Always retry the executed function when raised.N)r@ __module__ __qualname____doc__r3r3r3r4rLsrLc@s eZdZdS) DoAttemptNr@rMrNr3r3r3r4rPsrPc@s eZdZdS)DoSleepNrQr3r3r3r4rRsrRc@sReZdZUdZdZejeed<dZ ej eed<edddZ edd 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 r3 REPR_FIELDSNNAMEr1cs.dfddjD}jjd|dS)Nz, c3s"|]}|dt|VqdS)=N)getattr).0fieldselfr3r4 sz&BaseAction.__repr__..())joinrTr?r@)r\ state_strr3r[r4__repr__szBaseAction.__repr__cCst|Sr2)reprr[r3r3r4__str__szBaseAction.__str__) r@rMrNrOrTtSequencestr__annotations__rUOptionalrbrdr3r3r3r4rSs rSc@s&eZdZdZdZejddddZdS) RetryActionrr5N)rr1cCst||_dSr2)floatr)r\rr3r3r4__init__szRetryAction.__init__)r@rMrNrTrUre SupportsFloatrlr3r3r3r4rjsrj)firstsecondr1cCs|tkr |S|Sr2)_unset)rnror3r3r4 _first_setsrqcsDeZdZdZdddfdd Zddd d Zedd d ZZS) RetryErrorz>Encapsulates the last attempt instance right before giving up.FutureN) last_attemptr1cs||_t|dSr2)rtsuperrl)r\rtr?r3r4rlszRetryError.__init__z t.NoReturnrVcCs|jjr|j|dSr2)rtfailedresultr[r3r3r4reraises zRetryError.reraisecCs|jjd|jdS)N[])r?r@rtr[r3r3r4rdszRetryError.__str__) r@rMrNrOrlryrgrd __classcell__r3r3rvr4rrsrrc@s^eZdZdZddddZdddd Zejeje eje ejd eje d d d Z dS)AttemptManagerzManage attempt context.RetryCallState retry_statecCs ||_dSr2r)r\rr3r3r4rlszAttemptManager.__init__NrVcCsdSr2r3r[r3r3r4 __enter__szAttemptManager.__enter__types.TracebackType)exc_type exc_value tracebackr1cCs4t|tr |j|||fdS|jddSdS)NT)r< BaseExceptionr set_exception set_result)r\rrrr3r3r4__exit__s   zAttemptManager.__exit__) r@rMrNrOrlrreriTyperboolrr3r3r3r4r}sr}c@s>eZdZeeeeeedde df e j e j e efgdfddee j dgdfe j dgdfe je j dgdfee je e je j dge jfd ddZeeeeeeeeeef e j e j e j e efgdfefe j defe j defe j eefe j e j dgdfefe j e j dgdfefe j e je j dgdfefe j eefe j e je efe j e je j dge jfefdd d d Zed d dZee jee jfd ddZeedddZdd ddZde j e e!e jfdddZ"e j#e$ddfd ddZ%e&e j de'fe je je'dddZ(dS) BaseRetryingNFr,r+r~ rstopwaitr5beforeafter before_sleepryretry_error_clsretry_error_callbackc CsJ||_||_||_||_||_||_||_||_t |_ | |_ | |_ dSr2) rrrr5rrrry threadinglocal_localrr r\rrrr5rrrryrrr3r3r4rls  zBaseRetrying.__init__) rrrr5rrrryrrr1c 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.r) r?rqrrrr5rrrryrrrr3r3r4copys          zBaseRetrying.copyrVcCsLd|jjdt|dd|jd|jd|jd|jd|jd |jd S) N) r?r@idrrrr5rrr[r3r3r4rbsJzBaseRetrying.__repr__cCs4z |jjWStk r.i|j_|jjYSXdS)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). N)r statisticsAttributeErrorr[r3r3r4r"s  zBaseRetrying.statisticsr9csTttjtjtjdfdd }tjtjtdfdd }|_||_|S)z[Wrap a function for retrying. :param f: A function to wraps for retrying. )argskwr1csf||Sr2r3)rrr:r\r3r4 wrapped_fDsz%BaseRetrying.wraps..wrapped_f)rkwargsr1csj||Sr2)rrG)rrrr3r4 retry_withHsz&BaseRetrying.wraps..retry_with) functoolsrGreAnyr-r5r)r\r:rrr3rr4rG>s  zBaseRetrying.wrapscCs0|jt|jd<d|jd<d|jd<dS)N start_timerattempt_numberridle_for)rcleartime monotonicr[r3r3r4beginPs  zBaseRetrying.begin)rr1cCs(|j}|dkr(|jdk r"||tS|jjo>t|jt}|sX|j|dsX|S|j dk rl| ||j |j d<|j |dr|j r| |S||}|jr||||jr|j|d}nd}t||_|j|7_|j d|7<|j dd7<|jdk r ||t|S)Nrdelay_since_first_attemptrrr)outcomerrPrwr< exceptionrLr5rxrseconds_since_startrrrrryrrj next_actionrrrR)r\rfutis_explicit_retry retry_excrr3r3r4iterVs8            zBaseRetrying.iterccsb|t|ddid}|j|d}t|tr) rrwrr?r@rxrkroundrrr)r\rxrsleptclsnamer3r3r4rbs  zRetryCallState.__repr__)r@rMrNrOrrerir-rrlrrkrrrTuplerrrrbr3r3r3r4r~s "r~)rA)rE)Zrrrrtypingrer=abcrr concurrentrinspectrr5rrr r r r r rrrrrrnaprrrrrrrrrrrrrr r!r"r#r$wait_full_jitterrr%r&rr'r(rr)r*rB TYPE_CHECKINGtypesr+r,TypeVarrr-r/overloadrr ExceptionrLr NO_RESULTrPrkrRrSrjrprqrrr}rrFrsr~pip._vendor.tenacity._asynciorAZpip._vendor.tenacity.tornadowebrEr3r3r3r4s                                         $,"-F