a DOg.@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_MAXFZduplexwin32)Z synchronizer_maxsizerPipe_reader_writerLock_rlockosgetpid_opidsysplatform_wlockZBoundedSemaphore_sem _ignore_epipe_resetr r _after_forkselfmaxsizectxr&;/opt/alt/python39/lib64/python3.9/multiprocessing/queues.py__init__%s       zQueue.__init__cCs.t||j|j|j|j|j|j|j|j fSN) r assert_spawningrrrrrrrrr#r&r&r' __getstate__9s zQueue.__getstate__c Cs0|\|_|_|_|_|_|_|_|_|dSr)) rrrrrrrrr 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#r0r&r&r'r Gs    z Queue._resetTNcCsz|jrtd|d|j||s(t|j8|jdurB||j ||j Wdn1sl0YdSNzQueue z is closed) r< ValueErrorracquirerr2r9 _start_threadr8appendnotifyr#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 |SrD) r<rErrArreleasetime monotonicrFrrC_ForkingPicklerloads)r#rLrMresZdeadliner&r&r'getbs* &     z Queue.getcCs|j|jjSr))rr_semlockZ _get_valuer+r&r&r'qsize|sz Queue.qsizecCs | Sr)rCr+r&r&r'emptysz Queue.emptycCs |jjSr))rrV_is_zeror+r&r&r'fullsz Queue.fullcCs |dSr1)rUr+r&r&r' get_nowaitszQueue.get_nowaitcCs ||dSr1)rNr#rKr&r&r' put_nowaitszQueue.put_nowaitcCs d|_|j}|rd|_|dS)NT)r<r=)r#closer&r&r'r_s 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:ZcancelAttributeErrorr+r&r&r'cancel_join_threads  zQueue.cancel_join_threadc Cstd|jtjtj|j|j|j|j |j j |j j |j |j|jf dd|_d|j_td|jtd|jst|jtjt|jgdd|_t|tj|j|jgd d|_dS) NzQueue._start_thread()ZQueueFeederThread)targetargsnameTzdoing self._thread.start()z... done self._thread.start())Z exitpriority )r r8clearr4ZThreadr_feedr2r?rrr_rr_on_queue_feeder_errorrr9Zdaemonstartr;r _finalize_joinweakrefrefr:_finalize_closer=r+r&r&r'rGs4     zQueue._start_threadcCs4td|}|dur(|tdntddS)Nzjoining queue threadz... queue thread joinedz... queue thread already dead)r join)Ztwrthreadr&r&r'rls  zQueue._finalize_joincCsBtd|"|t|Wdn1s40YdS)Nztelling queue thread to quit)r rH _sentinelrI)buffernotemptyr&r&r'ros zQueue._finalize_closec  Csrtd|j} |j} |j} |j} t} tjdkr<|j}|j}nd}z| z|sT| W| n| 0zn| }|| urtd||WWdSt |}|dur||qh|z||W|qh|0qhWnt yYn0Wq@t yj}zf|r$t |ddt jkr$WYd}~dStrDtd|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 rFrOwaitpopleftrrrrrRdumps IndexError ExceptiongetattrruZEPIPErr )rsrtr>Z writelockZ reader_closeZ writer_closeZ ignore_epipeonerrorZ queue_semZnacquireZnreleaseZnwaitZbpopleftsentinelZwacquireZwreleaserKer&r&r'risP       z Queue._feedcCsddl}|dS)z Private API hook called when feeding data in the background thread raises an exception. For overriding by concurrent.futures. rN) traceback print_exc)r~rKrr&r&r'rjszQueue._on_queue_feeder_error)r)F)TN)TN)__name__ __module__ __qualname__r(r,r/r!r rNrUrWrYr[r\r^r_r`rbrG staticmethodrlrorirjr&r&r&r'r#s0   !   >rc@s@eZdZdddZddZddZdd d Zd d ZddZd S)rrcCs*tj|||d|d|_||_dS)N)r%r)rr(Z Semaphore_unfinished_tasksr5_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)rr/rrr-r&r&r'r/0szJoinableQueue.__setstate__TNc Cs|jrtd|d|j||s(t|jh|jB|jdurJ||j ||j |j Wdn1s~0YWdn1s0YdSrD)r<rErrFrr2rr9rGr8rHrrOrIrJr&r&r'rN4s   zJoinableQueue.putcCsT|j:|jdstd|jjr2|jWdn1sF0YdS)NFz!task_done() called too many times)rrrFrErVrZZ notify_allr+r&r&r' task_doneAs   zJoinableQueue.task_donecCs@|j&|jjs|jWdn1s20YdSr))rrrVrZrvr+r&r&r'rpHs zJoinableQueue.join)r)TN) rrrr(r,r/rNrrpr&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) rrrrrrrBrCrrr)r#r%r&r&r'r(Ss    zSimpleQueue.__init__cCs|j|jdSr))rr_rr+r&r&r'r_\s zSimpleQueue.closecCs | Sr)rXr+r&r&r'rY`szSimpleQueue.emptycCst||j|j|j|jfSr))r r*rrrrr+r&r&r'r,cs zSimpleQueue.__getstate__cCs"|\|_|_|_|_|jj|_dSr))rrrrrBrCr-r&r&r'r/gszSimpleQueue.__setstate__cCs:|j|j}Wdn1s&0Yt|Sr))rrr@rRrS)r#rTr&r&r'rUks(zSimpleQueue.getcCsXt|}|jdur"|j|n2|j|j|Wdn1sJ0YdSr))rRrxrrr>r]r&r&r'rNqs   zSimpleQueue.putN)rrrr(r_rYr,r/rUrN classmethodtypes GenericAlias__class_getitem__r&r&r&r'rQs  r)__all__rrr4r6rPrrmruZqueuerrZ_multiprocessingrr Z reductionZForkingPicklerrRutilr r r r robjectrrrrrr&r&r&r' s&  z +