a Z^.@sgdZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z ddl Z ddl mZddl mZejjZddlmZmZmZmZmZGdd d eZeZGd d d eZGd d d eZdS))Queue SimpleQueue JoinableQueueN)EmptyFull) connection)context)debuginfoFinalizeregister_after_fork is_exitingc@seZdZd-ddZddZddZdd Zd.d d Zd/ddZd0ddZ ddZ ddZ ddZ ddZ ddZddZdd Zd!d"Zd#d$Zed%d&Zed'd(Zed)d*Zed+d,ZdS)1rrcCs|dkrddlm}||_tjdd\|_|_||_t |_ t j dkrTd|_n ||_|||_d|_|t j dkrt|tjdS)Nrr) SEM_VALUE_MAXFduplexwin32) synchronizer_maxsizerPipe_reader_writerLock_rlockosgetpid_opidsysplatform_wlockBoundedSemaphore_sem _ignore_epipe_resetr r _after_forkselfmaxsizectxr)./usr/lib64/python3.9/multiprocessing/queues.py__init__%s       zQueue.__init__cCs.t||j|j|j|j|j|j|j|j fSN) r assert_spawningr"rrrrrr!rr&r)r)r* __getstate__9s zQueue.__getstate__c Cs0|\|_|_|_|_|_|_|_|_|dSr,) r"rrrrrr!rr#r&stater)r)r* __setstate__>szQueue.__setstate__cCstd|jdddS)NzQueue._after_fork()T) after_fork)r r#r.r)r)r*r$CszQueue._after_forkFcCsj|r|jntt|_t|_d|_d|_ d|_ d|_ d|_ |j j|_|jj|_|jj|_dSNF) _notempty_at_fork_reinit threading Conditionr collectionsdeque_buffer_thread _jointhread_joincancelled_closed_closer send_bytes _send_bytesr recv_bytes _recv_bytespoll_poll)r&r3r)r)r*r#Gs    z Queue._resetTNcCsz|jrtd|d|j||s(t|j8|jdurB||j ||j Wdn1sl0YdSNzQueue z is closed) r? ValueErrorr!acquirerr5r< _start_threadr;appendnotifyr&objblocktimeoutr)r)r*putVs  z Queue.putcCs|jrtd|d|r\|dur\|j|}Wdn1sF0Y|jn||rlt|}|j||s~t zL|r|t}| |st n | st |}|jW|jn |j0t |SrG) r?rHrrDr!releasetime monotonicrIrrF_ForkingPicklerloads)r&rOrPresdeadliner)r)r*getbs* &     z Queue.getcCs|j|jjSr,)rr!_semlock _get_valuer.r)r)r*qsize|sz Queue.qsizecCs | Sr,rFr.r)r)r*emptysz Queue.emptycCs |jjSr,)r!rZ_is_zeror.r)r)r*fullsz Queue.fullcCs |dSr4)rYr.r)r)r* get_nowaitszQueue.get_nowaitcCs ||dSr4)rQr&rNr)r)r* put_nowaitszQueue.put_nowaitcCsHd|_z$|jW|j}|rDd|_|n|j}|rBd|_|0dS)NT)r?rcloser@)r&rdr)r)r*rds z Queue.closecCstd|jr|dS)NzQueue.join_thread())r r=r.r)r)r* join_threadszQueue.join_threadcCs4tdd|_z|jWnty.Yn0dS)NzQueue.cancel_join_thread()T)r r>r=cancelAttributeErrorr.r)r)r*cancel_join_threads  zQueue.cancel_join_threadc Cstd|jtjtj|j|j|j|j |j j |j |j |jfdd|_d|j_td|jtd|jst|jtjt|jgdd|_t|tj|j|jgd d|_dS) NzQueue._start_thread()QueueFeederThread)targetargsnameTzdoing self._thread.start()z... done self._thread.start()) exitpriority )r r;clearr7Threadr_feedr5rBrrrdr"_on_queue_feeder_errorr!r<daemonstartr>r _finalize_joinweakrefrefr=_finalize_closer@r.r)r)r*rJs2     zQueue._start_threadcCs4td|}|dur(|tdntddS)Nzjoining queue threadz... queue thread joinedz... queue thread already dead)r join)twrthreadr)r)r*rvs  zQueue._finalize_joincCsBtd|"|t|Wdn1s40YdS)Nztelling queue thread to quit)r rK _sentinelrL)buffernotemptyr)r)r*rys zQueue._finalize_closec Csltd|j}|j} |j} |j} t} tjdkr<|j} |j}nd} z|z|sT| W| n| 0zh| }|| urtd|WWdSt |}| dur||qh| z||W|qh|0qhWnt yYn0Wq@t yd}zf|rt |ddt jkrWYd}~dStr>td|WYd}~dS||||WYd}~q@d}~00q@dS)Nz$starting thread to feed data to piperz%feeder thread got sentinel -- exitingerrnorzerror in queue thread: %s)r rIrRwaitpopleftr}rrrUdumps IndexError ExceptiongetattrrEPIPErr )r~rrA writelockrd ignore_epipeonerror queue_semnacquirenreleasenwaitbpopleftsentinelwacquirewreleaserNer)r)r*rrsN       z Queue._feedcCsddl}|dS)Nr) traceback print_exc)rrNrr)r)r*rsszQueue._on_queue_feeder_error)r)F)TN)TN)__name__ __module__ __qualname__r+r/r2r$r#rQrYr\r^r`rarcrdrerhrJ staticmethodrvryrrrsr)r)r)r*r#s0        =rc@s@eZdZdddZddZddZdd d Zd d ZddZd S)rrcCs*tj|||d|d|_||_dS)N)r(r)rr+ Semaphore_unfinished_tasksr8_condr%r)r)r*r+)s zJoinableQueue.__init__cCst||j|jfSr,)rr/rrr.r)r)r*r/.szJoinableQueue.__getstate__cCs,t||dd|dd\|_|_dS)N)rr2rrr0r)r)r*r21szJoinableQueue.__setstate__TNc Cs|jrtd|d|j||s(t|jh|jB|jdurJ||j ||j |j Wdn1s~0YWdn1s0YdSrG)r?rHr!rIrr5rr<rJr;rKrrRrLrMr)r)r*rQ5s   zJoinableQueue.putcCsT|j:|jdstd|jjr2|jWdn1sF0YdS)NFz!task_done() called too many times)rrrIrHrZr_ notify_allr.r)r)r* task_doneBs   zJoinableQueue.task_donecCs@|j&|jjs|jWdn1s20YdSr,)rrrZr_rr.r)r)r*rzIs zJoinableQueue.join)r)TN) rrrr+r/r2rQrrzr)r)r)r*r's   rc@sNeZdZddZddZddZddZd d Zd d Zd dZ e e j Z dS)rcCsHtjdd\|_|_||_|jj|_tj dkr:d|_ n ||_ dS)NFrr) rrrrrrrErFrrr)r&r(r)r)r*r+Ts    zSimpleQueue.__init__cCs|j|jdSr,)rrdrr.r)r)r*rd]s zSimpleQueue.closecCs | Sr,r]r.r)r)r*r^aszSimpleQueue.emptycCst||j|j|j|jfSr,)r r-rrrrr.r)r)r*r/ds zSimpleQueue.__getstate__cCs"|\|_|_|_|_|jj|_dSr,)rrrrrErFr0r)r)r*r2hszSimpleQueue.__setstate__cCs:|j|j}Wdn1s&0Yt|Sr,)rrrCrUrV)r&rWr)r)r*rYls(zSimpleQueue.getcCsXt|}|jdur"|j|n2|j|j|Wdn1sJ0YdSr,)rUrrrrArbr)r)r*rQrs   zSimpleQueue.putN)rrrr+rdr^r/r2rYrQ classmethodtypes GenericAlias__class_getitem__r)r)r)r*rRs  r)__all__rrr7r9rSrrwrqueuerr_multiprocessingrr reductionForkingPicklerrUutilr r r r robjectrr}rrr)r)r)r* s&  { +