K iJ#ddlZddlZddlZejrddlmZGddej Zejeejdge ffZ GddeZ e Z Gdd eZeZGd d eZGd d eZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZy) N)RetryCallStatec^eZdZdZej dddefdZd dZd dZ d dZ d d Z y ) retry_basez)Abstract base class for retry strategies. retry_staterreturncyNselfrs T/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/tenacity/retry.py__call__zretry_base.__call__s c$|j|Sr )__rand__r others r __and__zretry_base.__and__ s~~d##rct||Sr ) retry_allrs r rzretry_base.__rand__#%%rc$|j|Sr )__ror__rs r __or__zretry_base.__or__&s}}T""rct||Sr ) retry_anyrs r rzretry_base.__ror__)rrN)rrrr)rrrr) __name__ __module__ __qualname____doc__abcabstractmethodboolrrrrrr rr rrs@3 $4   $&#&rrrc eZdZdZdddefdZy) _retry_neverz-Retry strategy that never rejects any result.rrrcy)NFr r s r rz_retry_never.__call__3srNrrrr r#rr rr r%r%0s7$4rr%c eZdZdZdddefdZy) _retry_alwaysz.Retry strategy that always rejects any result.rrrcy)NTr r s r rz_retry_always.__call__=srNr'r rr r)r):s8$4rr)cPeZdZdZdej egefddfdZdddefdZ y) retry_if_exceptionzARetry strategy that retries if an exception verifies a predicate. predicaterNc||_yr r-r r-s r __init__zretry_if_exception.__init__G "rrrc|j td|jjr8|jj}| td|j |Sy)N(__call__() called before outcome was set(outcome failed but the exception is NoneFoutcome RuntimeErrorfailed exceptionr-r rr:s r rzretry_if_exception.__call__Jsa    &IJ J    % %#++557I "#MNN>>), ,r) rrrr typingCallable BaseExceptionr#r1rr rr r,r,Ds<K#&//=/42G"H#T# $4  rr,ceZdZdZefdej ejeejejedffddffd Z xZ S)retry_if_exception_typez=Retries if an exception has been raised of one or more types.exception_types.rNc:|_t| fdy)Nct|Sr  isinstanceerAs r z2retry_if_exception_type.__init__..bs:a#ArrAsuperr1r rA __class__s `r r1z retry_if_exception_type.__init__Zs / ABr rrrr Exceptionr<UnionTyper>Tupler1 __classcell__rLs@r r@r@Ws_G  C KK & LL]3S8 9 ; C  CCrr@ceZdZdZefdej ejeejejedffddffd Z xZ S)retry_if_not_exception_typezARetries except an exception has been raised of one or more types.rA.rNc:|_t| fdy)Nct| Sr rDrFs r rHz6retry_if_not_exception_type.__init__..pz!_'E#ErrIrKs `r r1z$retry_if_not_exception_type.__init__h / EFrrMrSs@r rUrUes_K  G KK & LL]3S8 9 ; G  GGrrUceZdZdZefdej ejeejejedffddffd Z ddde fd Z xZ S) retry_unless_exception_typez:Retries until an exception is raised of one or more types.rA.rNc:|_t| fdy)Nct| Sr rDrFs r rHz6retry_unless_exception_type.__init__..~rXrrIrKs `r r1z$retry_unless_exception_type.__init__vrYrrrc|j td|jjsy|jj}| td|j |SNr4Tr5r6r;s r rz$retry_unless_exception_type.__call__sc    &IJ J""))''113  IJ J~~i((r)rrrr rNr<rOrPr>rQr1r#rrRrSs@r r[r[ssmD  G KK & LL]3S8 9 ; G  G )$4 ) )rr[ceZdZdZefdej ejeejejedffddfdZ ddde fd Z y) retry_if_exception_cause_typezRetries if any of the causes of the raised exception is of one or more types. The check on the type of the cause of the exception is done recursively (until finding an exception in the chain that has no `__cause__`) rA.rNc||_yr )exception_cause_types)r rAs r r1z&retry_if_exception_cause_type.__init__s &5"rrrc|j td|jjrL|jj}|0t |j |j ry|j }|0y)Nz&__call__ called before outcome was setTF)r7r8r9r:rE __cause__rc)r rexcs r rz&retry_if_exception_cause_type.__call__sn    &GH H    % %%%//1C/cmmT-G-GHmm/ r) rrrr rNr<rOrPr>rQr1r#rr rr rarask  5 KK & LL]3S8 9 ; 5  5 $4  rracdeZdZdZdej ej gefddfdZdddefdZ y) retry_if_resultz+Retries if the result verifies a predicate.r-rNc||_yr r/r0s r r1zretry_if_result.__init__r2rrrc|j td|jjs)|j|jj SyNr4Fr7r8r9r-resultr s r rzretry_if_result.__call__sJ    &IJ J""))>>+"5"5"<"<">? ?r rrrr r<r=Anyr#r1rr rr rhrhs@5#&//6::,2D"E#$#$4rrhcdeZdZdZdej ej gefddfdZdddefdZ y) retry_if_not_resultz*Retries if the result refutes a predicate.r-rNc||_yr r/r0s r r1zretry_if_not_result.__init__r2rrrc|j td|jjs*|j|jj  Syrkrlr s r rzretry_if_not_result.__call__sM    &IJ J""))~~k&9&9&@&@&BCC Crrnr rr rqrqs@4#&//6::,2D"E#$#$4rrqc eZdZdZ ddej edejdeejefddffd Z xZ S)retry_if_exception_messagez2Retries if an exception message equals or matches.Nmessagematchrc>r$|r"t|jjdrdtdtffd }|}nN|r*t j |dtdtffd }|}n"t|jjdt|!|y)Nz.() takes either 'message' or 'match', not bothr:rc t|k(Sr )str)r:rvs r message_fncz8retry_if_exception_message.__init__..message_fncs#i.00rcJtjt|Sr )r#rwrz)r:progs r match_fncz6retry_if_exception_message.__init__..match_fncsDJJs9~677rz3() missing 1 required argument 'message' or 'match') TypeErrorrLrr>r#recompilerJr1)r rvrwr{r-r~r}rLs ` @r r1z#retry_if_exception_message.__init__s u>>**++YZ   1} 1 1$I ::e$D 8] 8t 8"I>>**++^_  #rNN) rrrr r<OptionalrzrOPatternr1rRrSs@r rurusV<)->B$%$||D#v~~c'::;$  $$rruc eZdZdZ d dej edejdeejefddffd Z ddde fd Z xZ S) retry_if_not_exception_messagez5Retries until an exception message equals or matches.NrvrwrcTt||||jfd|_y)Nc|i| Sr r )args_kwargs_ if_predicates r rHz9retry_if_not_exception_message.__init__..s|U7Vg7V3Vr)rJr1r-)r rvrwrrLs @r r1z'retry_if_not_exception_message.__init__s$ %(~~ Vrrrc|j td|jjsy|jj}| td|j |Sr_r6r;s r rz'retry_if_not_exception_message.__call__sa    &IJ J""))''113  IJ J~~i((rr) rrrr r<rrzrOrr1r#rrRrSs@r rrsi?)->BW%W||D#v~~c'::;W  W )$4 ) )rrc0eZdZdZdeddfdZdddefdZy) rz1Retries if any of the retries condition is valid.retriesrNc||_yr rr rs r r1zretry_any.__init__   rrrc@tfd|jDS)Nc3.K|] }|ywr r .0rrs r z%retry_any.__call__..8a1[>8)anyrr s `r rzretry_any.__call__84<<888rrrrr rr1r#rr rr rr s,;9$499rrc0eZdZdZdeddfdZdddefdZy) rz/Retries if all the retries condition are valid.rrNc||_yr rrs r r1zretry_all.__init__rrrrc@tfd|jDS)Nc3.K|] }|ywr r rs r rz%retry_all.__call__..rr)allrr s `r rzretry_all.__call__rrrr rr rrs,99$499rr)r!rr< TYPE_CHECKINGtenacityrABCrrOr=r# RetryBaseTr% retry_neverr) retry_alwaysr,r@rUr[rarhrqrurrrr rr rs "  '&&(\\*foo7G6H$6N&OO P :n J & C0 C G"4 G)"4)6J< j  *  $!3 $F)%?)49 99 9r