ó û^‚Rc@s8dddgZddlZddlZddlZddlZddlZddlZddlZddlm Z m Z ddl Z ddl m Z ddlmZmZmZmZddlmZmZmZmZdd lmZdefd „ƒYZeƒZdefd „ƒYZdefd „ƒYZdS( tQueuet SimpleQueuet JoinableQueueiÿÿÿÿN(tEmptytFull(tPipe(tLocktBoundedSemaphoret Semaphoret Condition(tdebugtinfotFinalizetregister_after_fork(tassert_spawningcBsËeZdd„Zd„Zd„Zd„Zedd„Zedd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zed„ƒZed„ƒZed„ƒZRS(icCsÀ|dkrtjj}n||_tdtƒ\|_|_tƒ|_ t j ƒ|_ t jdkrud|_n tƒ|_t|ƒ|_|jƒt jdkr¼t|tjƒndS(Nitduplextwin32(t_multiprocessingtSemLockt SEM_VALUE_MAXt_maxsizeRtFalset_readert_writerRt_rlocktostgetpidt_opidtsystplatformtNonet_wlockRt_semt _after_forkR R(tselftmaxsize((s,/usr/lib/python2.7/multiprocessing/queues.pyt__init__:s      cCs8t|ƒ|j|j|j|j|j|j|jfS(N(RRRRRRR R(R"((s,/usr/lib/python2.7/multiprocessing/queues.pyt __getstate__Ls cCs>|\|_|_|_|_|_|_|_|jƒdS(N(RRRRRR RR!(R"tstate((s,/usr/lib/python2.7/multiprocessing/queues.pyt __setstate__Qs0cCstdƒtjtjƒƒ|_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/lib/python2.7/multiprocessing/queues.pyR!Vs      cCs|j st‚|jj||ƒs.t‚n|jjƒz=|jdkrZ|jƒn|j j |ƒ|jj ƒWd|jj ƒXdS(N( R0tAssertionErrorR tacquireRR)R-Rt _start_threadR,tappendtnotifytrelease(R"tobjtblockttimeout((s,/usr/lib/python2.7/multiprocessing/queues.pytputcs   cCs|rT|dkrT|jjƒz!|jƒ}|jjƒ|SWd|jjƒXn¼|rmtjƒ|}n|jj||ƒs‹t‚nzt|rÌ|tjƒ}|dksÀ|j|ƒ rát‚qán|jƒsát‚n|jƒ}|jjƒ|SWd|jjƒXdS(Ni( RRR9R5R R=ttimeRR7(R"R?R@trestdeadline((s,/usr/lib/python2.7/multiprocessing/queues.pytgetqs,         cCs|j|jjjƒS(N(RR t_semlockt _get_value(R"((s,/usr/lib/python2.7/multiprocessing/queues.pytqsizescCs |jƒ S(N(R7(R"((s,/usr/lib/python2.7/multiprocessing/queues.pytempty‘scCs|jjjƒS(N(R RFt_is_zero(R"((s,/usr/lib/python2.7/multiprocessing/queues.pytfull”scCs |jtƒS(N(RER(R"((s,/usr/lib/python2.7/multiprocessing/queues.pyt get_nowait—scCs|j|tƒS(N(RAR(R"R>((s,/usr/lib/python2.7/multiprocessing/queues.pyt put_nowaitšscCs0t|_|jjƒ|jr,|jƒndS(N(tTrueR0RtcloseR1(R"((s,/usr/lib/python2.7/multiprocessing/queues.pyROs   cCs3tdƒ|jst‚|jr/|jƒndS(NsQueue.join_thread()(R R0R8R.(R"((s,/usr/lib/python2.7/multiprocessing/queues.pyt join_thread£s  cCs<tdƒt|_y|jjƒWntk r7nXdS(NsQueue.cancel_join_thread()(R RNR/R.tcanceltAttributeError(R"((s,/usr/lib/python2.7/multiprocessing/queues.pytcancel_join_thread©s    c Csótdƒ|jjƒtjdtjd|j|j|j|j |j j fddƒ|_ t |j _tdƒ|j jƒtdƒ|jsÅt|j tjtj|j ƒgdd ƒ|_nt|tj|j|jgdd ƒ|_dS( NsQueue._start_thread()ttargettargstnametQueueFeederThreadsdoing self._thread.start()s... done self._thread.start()t exitpriorityiûÿÿÿi (R R,tclearR(tThreadRt_feedR)R3RRROR-RNtdaemontstartR/R t_finalize_jointweakreftrefR.t_finalize_closeR1(R"((s,/usr/lib/python2.7/multiprocessing/queues.pyR:±s(            cCsDtdƒ|ƒ}|dk r6|jƒtdƒn tdƒdS(Nsjoining queue threads... queue thread joineds... queue thread already dead(R Rtjoin(ttwrtthread((s,/usr/lib/python2.7/multiprocessing/queues.pyR^Ñs      cCsAtdƒ|jƒz|jtƒ|jƒWd|jƒXdS(Nstelling queue thread to quit(R R9R;t _sentinelR<R=(tbuffertnotempty((s,/usr/lib/python2.7/multiprocessing/queues.pyRaÛs    cCs€tdƒddlm}|j}|j}|j}|j} t} tj dkrh|j} |j} nd} y±xª|ƒz|sŽ|ƒnWd|ƒXymxf| ƒ} | | krÊtdƒ|ƒdS| dkrã|| ƒq | ƒz|| ƒWd| ƒXq Wqtt k rqtXqtWnZt k r{}y3|ƒrMt d|ƒnddl}|jƒWq|t k rwq|XnXdS(Ns$starting thread to feed data to pipei(t is_exitingRs%feeder thread got sentinel -- exitingserror in queue thread: %siÿÿÿÿ(R tutilRhR9R=twaittpopleftReRRRt IndexErrort ExceptionR t tracebackt print_exc(RfRgR2t writelockRORhtnacquiretnreleasetnwaittbpoplefttsentineltwacquiretwreleaseR>teRn((s,/usr/lib/python2.7/multiprocessing/queues.pyR[åsR                 N(t__name__t __module__R$R%R'R!RNRRARERHRIRKRLRMRORPRSR:t staticmethodR^RaR[(((s,/usr/lib/python2.7/multiprocessing/queues.pyR8s$               cBsGeZdd„Zd„Zd„Zedd„Zd„Zd„Z RS(icCs/tj||ƒtdƒ|_tƒ|_dS(Ni(RR$Rt_unfinished_tasksR t_cond(R"R#((s,/usr/lib/python2.7/multiprocessing/queues.pyR$)scCstj|ƒ|j|jfS(N(RR%R}R|(R"((s,/usr/lib/python2.7/multiprocessing/queues.pyR%.scCs.tj||d ƒ|d\|_|_dS(Niþÿÿÿ(RR'R}R|(R"R&((s,/usr/lib/python2.7/multiprocessing/queues.pyR'1scCs´|j st‚|jj||ƒs.t‚n|jjƒ|jjƒzJ|jdkrg|j ƒn|j j |ƒ|j j ƒ|jjƒWd|jj ƒ|jj ƒXdS(N(R0R8R R9RR)R}R-RR:R,R;R|R=R<(R"R>R?R@((s,/usr/lib/python2.7/multiprocessing/queues.pyRA5s      cCsi|jjƒzG|jjtƒs1tdƒ‚n|jjjƒrS|jjƒnWd|jjƒXdS(Ns!task_done() called too many times( R}R9R|Rt ValueErrorRFRJt notify_allR=(R"((s,/usr/lib/python2.7/multiprocessing/queues.pyt task_doneFs cCsH|jjƒz&|jjjƒs2|jjƒnWd|jjƒXdS(N(R}R9R|RFRJRjR=(R"((s,/usr/lib/python2.7/multiprocessing/queues.pyRbPs  N( RyRzR$R%R'RNRRAR€Rb(((s,/usr/lib/python2.7/multiprocessing/queues.pyR's     cBs5eZd„Zd„Zd„Zd„Zd„ZRS(cCs\tdtƒ\|_|_tƒ|_tjdkrBd|_ n tƒ|_ |j ƒdS(NRR( RRRRRRRRRRt _make_methods(R"((s,/usr/lib/python2.7/multiprocessing/queues.pyR$^s    cCs|jjƒ S(N(RR6(R"((s,/usr/lib/python2.7/multiprocessing/queues.pyRIgscCs&t|ƒ|j|j|j|jfS(N(RRRRR(R"((s,/usr/lib/python2.7/multiprocessing/queues.pyR%js cCs,|\|_|_|_|_|jƒdS(N(RRRRR(R"R&((s,/usr/lib/python2.7/multiprocessing/queues.pyR'nscs«|jj‰|jj|jj‰‰‡‡‡fd†}||_|jdkrd|jj |_ nC|jj ‰|jj|jj‰‰‡‡‡fd†}||_ dS(Ncs!ˆƒz ˆƒSWdˆƒXdS(N(((tracquireR4trrelease(s,/usr/lib/python2.7/multiprocessing/queues.pyREus cs$ˆƒzˆ|ƒSWdˆƒXdS(N((R>(R2RvRw(s,/usr/lib/python2.7/multiprocessing/queues.pyRAƒs( RR4RR9R=RERRRR2RA(R"RERA((R‚R4RƒR2RvRws,/usr/lib/python2.7/multiprocessing/queues.pyRrs   (RyRzR$RIR%R'R(((s,/usr/lib/python2.7/multiprocessing/queues.pyR\s    (t__all__RRR(R*RBtatexitR_RRRRtmultiprocessingRtmultiprocessing.synchronizeRRRR tmultiprocessing.utilR R R R tmultiprocessing.forkingRtobjectReRR(((s,/usr/lib/python2.7/multiprocessing/queues.pyt#s"        ""å 5