7ec@s>dddgZddlZddlZddlZddlZddlZddlZddlZddlm Z m Z ddl Z ddl m Z ddlmZmZmZmZdd lmZmZmZmZmZdd lmZdefd YZeZdefd YZdefd YZdS(tQueuet SimpleQueuet JoinableQueueiN(tEmptytFulli(tPipe(tLocktBoundedSemaphoret Semaphoret Condition(tdebugtinfotFinalizetregister_after_forkt is_exiting(tassert_spawningcBseZddZdZdZdZeddZeddZ dZ dZ d Z d Z d Zd Zd ZdZdZedZedZedZRS(icCs|dkrtjj}n||_tdt\|_|_t|_ t j |_ t jdkrud|_n t|_t||_|jt jdkrt|tjndS(Nitduplextwin32(t_multiprocessingtSemLockt SEM_VALUE_MAXt_maxsizeRtFalset_readert_writerRt_rlocktostgetpidt_opidtsystplatformtNonet_wlockRt_semt _after_forkR R(tselftmaxsize((s./usr/lib64/python2.7/multiprocessing/queues.pyt__init__:s      cCs8t||j|j|j|j|j|j|jfS(N(RRRRRR R!R(R#((s./usr/lib64/python2.7/multiprocessing/queues.pyt __getstate__Ls cCs>|\|_|_|_|_|_|_|_|jdS(N(RRRRR R!RR"(R#tstate((s./usr/lib64/python2.7/multiprocessing/queues.pyt __setstate__Qs0cCstdtjtj|_tj|_d|_ d|_ t |_ t |_ d|_|jj|_|jj|_|jj|_dS(NsQueue._after_fork()(R t threadingR Rt _notemptyt collectionstdequet_bufferRt_threadt _jointhreadRt_joincancelledt_closedt_closeRtsendt_sendRtrecvt_recvtpollt_poll(R#((s./usr/lib64/python2.7/multiprocessing/queues.pyR"Vs      cCs|j st|jj||s.tn|jjz=|jdkrZ|jn|j j ||jj Wd|jj XdS(N( R1tAssertionErrorR!tacquireRR*R.Rt _start_threadR-tappendtnotifytrelease(R#tobjtblockttimeout((s./usr/lib64/python2.7/multiprocessing/queues.pytputcs   cCs|rT|dkrT|jjz!|j}|jj|SWd|jjXn|rmtj|}n|jj||stnzg|r|tj}|j|stqn|jstn|j}|jj|SWd|jjXdS(N( RRR:R6R!R>ttimeRR8(R#R@RAtrestdeadline((s./usr/lib64/python2.7/multiprocessing/queues.pytgetqs,         cCs|j|jjjS(N(RR!t_semlockt _get_value(R#((s./usr/lib64/python2.7/multiprocessing/queues.pytqsizescCs |j S(N(R8(R#((s./usr/lib64/python2.7/multiprocessing/queues.pytemptyscCs|jjjS(N(R!RGt_is_zero(R#((s./usr/lib64/python2.7/multiprocessing/queues.pytfullscCs |jtS(N(RFR(R#((s./usr/lib64/python2.7/multiprocessing/queues.pyt get_nowaitscCs|j|tS(N(RBR(R#R?((s./usr/lib64/python2.7/multiprocessing/queues.pyt put_nowaitscCsDt|_z|jjWd|j}|r?d|_|nXdS(N(tTrueR1RtcloseR2R(R#RP((s./usr/lib64/python2.7/multiprocessing/queues.pyRPs   cCs3td|jst|jr/|jndS(NsQueue.join_thread()(R R1R9R/(R#((s./usr/lib64/python2.7/multiprocessing/queues.pyt join_threads  cCs<tdt|_y|jjWntk r7nXdS(NsQueue.cancel_join_thread()(R ROR0R/tcanceltAttributeError(R#((s./usr/lib64/python2.7/multiprocessing/queues.pytcancel_join_threads    c Cstd|jjtjdtjd|j|j|j|j |j j fdd|_ t |j _td|j jtd|jst|j tjtj|j gdd |_nt|tj|j|jgdd |_dS( NsQueue._start_thread()ttargettargstnametQueueFeederThreadsdoing self._thread.start()s... done self._thread.start()t exitpriorityii (R R-tclearR)tThreadRt_feedR*R4R RRPR.ROtdaemontstartR0R t_finalize_jointweakreftrefR/t_finalize_closeR2(R#((s./usr/lib64/python2.7/multiprocessing/queues.pyR;s(            cCsDtd|}|dk r6|jtdn tddS(Nsjoining queue threads... queue thread joineds... queue thread already dead(R Rtjoin(ttwrtthread((s./usr/lib64/python2.7/multiprocessing/queues.pyR_s      cCsAtd|jz|jt|jWd|jXdS(Nstelling queue thread to quit(R R:R<t _sentinelR=R>(tbuffertnotempty((s./usr/lib64/python2.7/multiprocessing/queues.pyRbs    cCs[td|j}|j}|j}|j}t} tjdkrX|j} |j} nd} xy|z|s~|nWd|Xynxg|} | | krtd|dS| dkr|| q| z|| Wd| XqWWnt k r nXWqat k rR} t r9t d| dSddl }|jqaXqaWdS(Ns$starting thread to feed data to pipeRs%feeder thread got sentinel -- exitingserror in queue thread: %si(R R:R>twaittpopleftRfRRRt IndexErrort ExceptionRR t tracebackt print_exc(RgRhR3t writelockRPtnacquiretnreleasetnwaittbpoplefttsentineltwacquiretwreleaseR?teRm((s./usr/lib64/python2.7/multiprocessing/queues.pyR\sL                N(t__name__t __module__R%R&R(R"RORRBRFRIRJRLRMRNRPRQRTR;t staticmethodR_RbR\(((s./usr/lib64/python2.7/multiprocessing/queues.pyR8s$              cBsGeZddZdZdZeddZdZdZ RS(icCs/tj||td|_t|_dS(Ni(RR%Rt_unfinished_tasksR t_cond(R#R$((s./usr/lib64/python2.7/multiprocessing/queues.pyR%)scCstj||j|jfS(N(RR&R|R{(R#((s./usr/lib64/python2.7/multiprocessing/queues.pyR&.scCs.tj||d |d\|_|_dS(Ni(RR(R|R{(R#R'((s./usr/lib64/python2.7/multiprocessing/queues.pyR(1scCs|j st|jj||s.tn|jj|jjzJ|jdkrg|j n|j j ||j j |jjWd|jj |jj XdS(N(R1R9R!R:RR*R|R.RR;R-R<R{R>R=(R#R?R@RA((s./usr/lib64/python2.7/multiprocessing/queues.pyRB5s      cCsi|jjzG|jjts1tdn|jjjrS|jjnWd|jjXdS(Ns!task_done() called too many times( R|R:R{Rt ValueErrorRGRKt notify_allR>(R#((s./usr/lib64/python2.7/multiprocessing/queues.pyt task_doneFs cCsH|jjz&|jjjs2|jjnWd|jjXdS(N(R|R:R{RGRKRiR>(R#((s./usr/lib64/python2.7/multiprocessing/queues.pyRcPs  N( RxRyR%R&R(RORRBRRc(((s./usr/lib64/python2.7/multiprocessing/queues.pyR's     cBs5eZdZdZdZdZdZRS(cCs\tdt\|_|_t|_tjdkrBd|_ n t|_ |j dS(NRR( RRRRRRRRRR t _make_methods(R#((s./usr/lib64/python2.7/multiprocessing/queues.pyR%^s    cCs|jj S(N(RR7(R#((s./usr/lib64/python2.7/multiprocessing/queues.pyRJgscCs&t||j|j|j|jfS(N(RRRRR (R#((s./usr/lib64/python2.7/multiprocessing/queues.pyR&js cCs,|\|_|_|_|_|jdS(N(RRRR R(R#R'((s./usr/lib64/python2.7/multiprocessing/queues.pyR(nscs|jj|jj|jjfd}||_|jdkrd|jj |_ nC|jj |jj|jjfd}||_ dS(Ncs!z SWdXdS(N(((tracquireR5trrelease(s./usr/lib64/python2.7/multiprocessing/queues.pyRFus cs$z|SWdXdS(N((R?(R3RuRv(s./usr/lib64/python2.7/multiprocessing/queues.pyRBs( RR5RR:R>RFR RRR3RB(R#RFRB((RR5RR3RuRvs./usr/lib64/python2.7/multiprocessing/queues.pyRrs   (RxRyR%RJR&R(R(((s./usr/lib64/python2.7/multiprocessing/queues.pyR\s    (t__all__RRR)R+RCtatexitR`RRRRtRt synchronizeRRRR tutilR R R R RtforkingRtobjectRfRR(((s./usr/lib64/python2.7/multiprocessing/queues.pyt#s"        "( 5