K i`ddlZddlZddlmZejr ddlZddlmZGddejZejeejdge ffZ GddeZ Gd d eZGd d eZeZGd deZGddeZGddeZGddeZy)N)_utils)RetryCallStatecNeZdZdZej dddefdZd dZd dZ y) stop_basez(Abstract base class for stop strategies. retry_staterreturncyNselfrs S/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/tenacity/stop.py__call__zstop_base.__call__s ct||Sr )stop_allr others r__and__zstop_base.__and__"e$$rct||Sr )stop_anyrs r__or__zstop_base.__or__%rrN)rrrr)rrrr) __name__ __module__ __qualname____doc__abcabstractmethodboolrrrr rrrrs62 $4   %%rrrc0eZdZdZdeddfdZdddefdZy) rz+Stop if any of the stop condition is valid.stopsrNc||_yr r"r r"s r__init__zstop_any.__init__/  rrrc@tfd|jDS)Nc3.K|] }|ywr r .0xrs r z$stop_any.__call__..36a1[>6)anyr"r s `rrzstop_any.__call__264::666rrrrrrr&r rr rrrr,s,5yT7$477rrc0eZdZdZdeddfdZdddefdZy) rz*Stop if all the stop conditions are valid.r"rNc||_yr r$r%s rr&zstop_all.__init__9r'rrrc@tfd|jDS)Nc3.K|] }|ywr r r*s rr-z$stop_all.__call__..=r.r/)allr"r s `rrzstop_all.__call__<r1rr2r rrrr6s,4yT7$477rrc eZdZdZdddefdZy) _stop_neverz Never stop.rrrcy)NFr r s rrz_stop_never.__call__CsrN)rrrrr rr rrr9r9@s$4rr9c(eZdZdZddZdddefdZy) stop_when_event_setz!Stop when the given event is set.rNc||_yr )event)r r>s rr&zstop_when_event_set.__init__Mr'rrrc6|jjSr )r>is_setr s rrzstop_when_event_set.__call__Pszz  ""r)r>zthreading.EventrN)rrrrr&r rr rrr<r<Js+#$4##rr<c0eZdZdZdeddfdZdddefdZy) stop_after_attemptz.Stop when the previous attempt >= max_attempt.max_attempt_numberrNc||_yr )rC)r rCs rr&zstop_after_attempt.__init__Ws "4rrrc4|j|jk\Sr )attempt_numberrCr s rrzstop_after_attempt.__call__Zs))T-D-DDDr)rrrrintr&r rr rrrBrBTs/853545E$4EErrBcDeZdZdZdej ddfdZdddefdZy) stop_after_delayaS Stop when the time from the first attempt >= limit. Note: `max_delay` will be exceeded, so when used with a `wait`, the actual total delay will be greater than `max_delay` by some of the final sleep period before `max_delay` is exceeded. If you need stricter timing with waits, consider `stop_before_delay` instead. max_delayrNc8tj||_yr r to_secondsrJr rJs rr&zstop_after_delay.__init__h**95rrrcb|j td|j|jk\SNz4__call__() called but seconds_since_start is not set)seconds_since_start RuntimeErrorrJr s rrzstop_after_delay.__call__ks/  * * 2UV V..$..@@r rrrrrtime_unit_typer&r rr rrrIrI^s76&"7"76D6A$4AArrIcDeZdZdZdej ddfdZdddefdZy) stop_before_delaya Stop right before the next attempt would take place after the time from the first attempt >= limit. Most useful when you are using with a `wait` function like wait_random_exponential, but need to make sure that the max_delay is not exceeded. rJrNc8tj||_yr rLrNs rr&zstop_before_delay.__init__yrOrrrc||j td|j|jz|jk\SrQ)rRrSupcoming_sleeprJr s rrzstop_before_delay.__call__|s?  * * 2UV V  + +k.H.H H~~  rrTr rrrWrWqs46&"7"76D6 $4  rrW)rtypingtenacityr TYPE_CHECKING threadingrABCrUnionCallabler StopBaseTrrr9 stop_neverr<rBrIrWr rrrds   ' % % LLFOO5E4F4L$MM N 7y77y7)] #)#EEAyA&  r