Xj*ddlmZdZddlZddlmZmZddlmZm Z ddl m Z ddl m Z mZmZdd lmZmZmZmZdd lmZdd lmZmZdd lmZmZdd lmZedZeddZ eddZ!GddeZ"edGdde eZ#edGdde eZ$edGdde e ee Z%edGdde e!ee!Z&y) ) annotations)MemoryObjectReceiveStreamMemoryObjectSendStreamMemoryObjectStreamStatisticsN) OrderedDictdeque) dataclassfield) TracebackType)Generic NamedTupleTypeVar)BrokenResourceErrorClosedResourceError EndOfStream WouldBlock)Event)TaskInfoget_current_task)ObjectReceiveStreamObjectSendStream) checkpointT_ItemT_coT) covariantT_contra) contravariantcJeZdZUded<ded<ded<ded<ded<ded<y ) rintcurrent_buffer_usedfloatmax_buffer_sizeopen_send_streamsopen_receive_streamstasks_waiting_sendtasks_waiting_receiveN)__name__ __module__ __qualname____annotations__h/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/venv/lib/python3.12/site-packages/anyio/streams/memory.pyrrs&r-rF)eqcPeZdZUedeZded<edZded<d dZy ) _MemoryObjectItemReceiverFinitdefault_factoryr task_info)r3ritemcnt|dd}|jjd|jd|dS)Nr6z (task_info=z, item=))getattr __class__r(r5)selfr6s r.__repr__z"_MemoryObjectItemReceiver.__repr__0s<tVT*..))*+dnn5EWTHTUVVr-N)returnstr) r(r)r*r rr5r+r6r<r,r-r.r1r1+s)U#>#C#C#EF ( EIIK 6r-c,K|jywrIrorKs r.aclosez MemoryObjectReceiveStream.aclose c6|jjSzj Return statistics about the current state of this stream. .. versionadded:: 3.0 rOrLrKs r.rLz$MemoryObjectReceiveStream.statistics {{%%''r-c|SrIr,rKs r. __enter__z#MemoryObjectReceiveStream.__enter__ r-c$|jyrIrqr;exc_typeexc_valexc_tbs r.__exit__z"MemoryObjectReceiveStream.__exit__ r-c|jsCtjd|jjdt |ddt d|yyNz Unclosed rT) stacklevelsourcerQwarningswarnr:r(idResourceWarningrKs r.__del__z!MemoryObjectReceiveStream.__del__F|| MMT^^445T"T(1QG  r-Nr=None)r=r)r=zMemoryObjectReceiveStream[T_co]rMr~ztype[BaseException] | NonerzBaseException | NonerzTracebackType | Noner=r)r(r)r*r+r rQrUr^rerhrorrrLrzrrr,r-r.rrOsq **ue4GT4/8,( = (,&%   r-rceZdZUded<eddZded<ddZddZdd Zdd Z dd Z dd Z dd Z ddZ ddZddZy)rz"_MemoryObjectStreamState[T_contra]rOFrBrPrQcB|jxjdz c_yrS)rOrDrKs r.rUz$MemoryObjectSendStream.__post_init__s &&!+&r-c2|jrt|jjst|jj rr|jj j d\}}|jjs||_ |jy|jj rrt|jj|jjkr&|jjj|yt)a Send an item immediately if it can be done without waiting. :param item: the item to send :raises ~anyio.ClosedResourceError: if this send stream has been closed :raises ~anyio.BrokenResourceError: if the stream has been closed from the receiving end :raises ~anyio.WouldBlock: if the buffer is full and there are no tasks waiting to receive FrWN)rQrrOrErrFrYr5has_pending_cancellationr6r[rJrAr#rZr)r;r6rcrds r. send_nowaitz"MemoryObjectSendStream.send_nowaits <<% %{{00% %kk++&*kk&C&C&K&KQV&K&W #M8%%>>@ $ !!# kk++ t{{!! "T[[%@%@ @ KK   % %d + r-cKtd{ |j|y7#t$rt}||jj |< |j d{7n4#t$r(|jj j|dwxYw||jj vr|jj |=tdYywxYww)a Send an item to the stream. If the buffer is full, this method blocks until there is again room in the buffer or the item can be sent directly to a receiver. :param item: the item to send :raises ~anyio.ClosedResourceError: if this send stream has been closed :raises ~anyio.BrokenResourceError: if the stream has been closed from the receiving end N) rrrrrOrGr` BaseExceptionrar)r;r6r]s r.sendzMemoryObjectSendStream.sendsl 4   T "  4J6:DKK ' ' 3  oo'''   ++// DA T[[888KK// ;)t39 4sRC!(C!*C!,CA1*A-+A10C11B""9CC!CC!cR|jrtt|jS)a  Create a clone of this send stream. Each clone can be closed separately. Only when all clones have been closed will the sending end of the memory stream be considered closed by the receiving ends. :return: the cloned stream rg)rQrrrOrKs r.rhzMemoryObjectSendStream.clone s  <<% %%T[[99r-cn|jsd|_|jxjdzc_|jjdk(rit|jjj }|jjj |D]}|jyyyrj)rQrOrDrkrFrlclearr[)r;receive_eventsrns r.rozMemoryObjectSendStream.closes||DL KK * *a / *{{--2!%dkk&C&C&H&H&J!K --335+ EIIK 3r-c,K|jywrIrqrKs r.rrzMemoryObjectSendStream.aclose)rsrtc6|jjSrvrwrKs r.rLz!MemoryObjectSendStream.statistics,rxr-c|SrIr,rKs r.rzz MemoryObjectSendStream.__enter__4r{r-c$|jyrIrqr}s r.rzMemoryObjectSendStream.__exit__7rr-c|jsCtjd|jjdt |ddt d|yyrrrKs r.rzMemoryObjectSendStream.__del__?rr-Nr)r6rr=r)r=z MemoryObjectSendStream[T_contra]rMr)r(r)r*r+r rQrUrrrhrorrrLrzrrr,r-r.rrsq ..ue4GT4,:4< : "(,&%   r-r)' __future__r__all__r collectionsrr dataclassesr r typesr typingr r rrrrr_core._synchronizationr_core._testingrrabcrrlowlevelrrrrrr1r@rrr,r-r.rs"  *(// +77!  v& :T 2 :  eWWW e wv  . es /B4/Hssl eWX.0@0Jr-