a  zeQG@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_/opt/bitninja-python-dojo/embedded/lib/python3.9/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 rrfr1cst|tr*td|jjd|jjdt|rBti}n:trnt tj drntj |rnt 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: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 z&BaseAction.__repr__..())joinrTr?r@)r\ state_strr3r[r4__repr__szBaseAction.__repr__cCst|Sr2)reprr[r3r3r4__str__szBaseAction.__str__) r@rMrNrOrTtSequencestr__annotations__rUOptionalrcrer3r3r3r4rSs rSc@s&eZdZdZdZejddddZdS) RetryActionrr5N)rr1cCst||_dSr2)floatr)r\rr3r3r4__init__szRetryAction.__init__)r@rMrNrTrUrf SupportsFloatrmr3r3r3r4rksrk)firstsecondr1cCs|tur |S|Sr2)_unset)rorpr3r3r4 _first_setsrrcsDeZdZdZdddfdd Zddd d Zedd d ZZS) RetryErrorz>Encapsulates the last attempt instance right before giving up.FutureN) last_attemptr1cs||_t|dSr2)rusuperrm)r\rur?r3r4rmszRetryError.__init__z t.NoReturnrVcCs|jjr|j|dSr2)rufailedresultr[r3r3r4reraises zRetryError.reraisecCs|jjd|jdS)N[])r?r@rur[r3r3r4reszRetryError.__str__) r@rMrNrOrmrzrhre __classcell__r3r3rwr4rssrsc@s^eZdZdZddddZdddd Zejeje eje ejd eje d d d Z dS)AttemptManagerzManage attempt context.RetryCallState retry_statecCs ||_dSr2r)r\rr3r3r4rmszAttemptManager.__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@rMrNrOrmrrfrjTyperboolrr3r3r3r4r~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_sleeprzretry_error_clsretry_error_callbackc CsJ||_||_||_||_||_||_||_||_t |_ | |_ | |_ dSr2) rrrr5rrrrz threadinglocal_localrr r\rrrr5rrrrzrrr3r3r4rms  zBaseRetrying.__init__) rrrr5rrrrzrrr1c 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?rrrrrr5rrrrzrrrr3r3r4copys          zBaseRetrying.copyrVcCsLd|jjdt|dd|jd|jd|jd|jd|jd |jd S) N) r?r@idrrrr5rrr[r3r3r4rcszBaseRetrying.__repr__cCs2z |jjWSty,i|j_|jjYS0dS)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. )argskwr1csg|Ri|Sr2r3)rrr:r\r3r4 wrapped_fDsz%BaseRetrying.wraps..wrapped_f)rkwargsr1csj|i|Sr2)rrG)rrrr3r4 retry_withHsz&BaseRetrying.wraps..retry_with) functoolsrGrfAnyr-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}|dur(|jdur"||tS|jjo>t|jt}|sX|j|dsX|S|j durl| ||j |j d<|j |dr|j r| |S||}|jr||||jr|j|d}nd}t||_|j|7_|j d|7<|j dd7<|jdur ||t|S)Nrdelay_since_first_attemptrrr)outcomerrPrxr< exceptionrLr5ryrseconds_since_startrrrrrzrrk next_actionrrrR)r\rfutis_explicit_retry retry_excrr3r3r4iterVs8            zBaseRetrying.iterccsb|t|ddid}|j|d}t|tr) rrxrr?r@ryrlroundrrr)r\ryrsleptclsnamer3r3r4rcs  zRetryCallState.__repr__)r@rMrNrOrrfrjr-rrmrrlrrrTuplerrrrcr3r3r3r4rs "r)rA)rE)Zrrrrtypingrfr=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_RESULTrPrlrRrSrkrqrrrsr~rrFrtrpip._vendor.tenacity._asynciorAZpip._vendor.tenacity.tornadowebrEr3r3r3r4s                                         $,"-F