mς %U²Ic@srdZdklZdklZdddgZdefd„ƒYZdefd„ƒYZdfd„ƒYZ d S( s'A multi-producer, multi-consumer queue.(stime(sdequetEmptytFulltQueuecBstZdZRS(s4Exception raised by Queue.get(block=0)/get_nowait().(t__name__t __module__t__doc__(((t"/data/zmath/lib/python2.4/Queue.pyRs cBstZdZRS(s4Exception raised by Queue.put(block=0)/put_nowait().(RRR(((RR s cBs•tZdd„Zd„Zd„Zd„Zedd„Zd„Z edd„Z d „Z d „Z d „Z d „Zd „Zd„Zd„ZRS(NicCsvy dk}Wntj odk}nX|i|ƒ|iƒ|_|i|iƒ|_ |i|iƒ|_ dS(svInitialize a queue object with a given maximum size. If maxsize is <= 0, the queue size is infinite. N( t threadingt ImportErrortdummy_threadingtselft_inittmaxsizetLocktmutext Conditiont not_emptytnot_full(R R R((Rt__init__s  cCs*|iiƒ|iƒ}|iiƒ|S(s9Return the approximate size of the queue (not reliable!).N(R Rtacquiret_qsizetntrelease(R R((Rtqsize's    cCs*|iiƒ|iƒ}|iiƒ|S(sCReturn True if the queue is empty, False otherwise (not reliable!).N(R RRt_emptyRR(R R((Rtempty.s    cCs*|iiƒ|iƒ}|iiƒ|S(sBReturn True if the queue is full, False otherwise (not reliable!).N(R RRt_fullRR(R R((Rtfull5s    cCs|iiƒzζ|p|iƒo t‚qΨn§|djo&x–|iƒo|iiƒqBWnt|djot dƒ‚nt ƒ|}xF|iƒo8|t ƒ}|djo t‚n|ii|ƒq’W|i |ƒ|iiƒWd|iiƒXdS(sPut an item into the queue. If optional args 'block' is true and 'timeout' is None (the default), block if necessary until a free slot is available. If 'timeout' is a positive number, it blocks at most 'timeout' seconds and raises the Full exception if no free slot was available within that time. Otherwise ('block' is false), put an item on the queue if a free slot is immediately available, else raise the Full exception ('timeout' is ignored in that case). is#'timeout' must be a positive numberf0.0N(R RRtblockRRttimeouttNonetwaitt ValueErrort_timetendtimet remainingt_puttitemRtnotifyR(R R%RRR#R"((Rtput<s.            cCs|i|tƒS(s©Put an item into the queue without blocking. Only enqueue the item if a free slot is immediately available. Otherwise raise the Full exception. N(R R'R%tFalse(R R%((Rt put_nowait]scCs |iiƒzι|p|iƒo t‚qΨn§|djo&x–|iƒo|iiƒqBWnt|djot dƒ‚nt ƒ|}xF|iƒo8|t ƒ}|djo t‚n|ii|ƒq’W|i ƒ}|iiƒ|SWd|iiƒXdS(sRemove and return an item from the queue. If optional args 'block' is true and 'timeout' is None (the default), block if necessary until an item is available. If 'timeout' is a positive number, it blocks at most 'timeout' seconds and raises the Empty exception if no item was available within that time. Otherwise ('block' is false), return an item if one is immediately available, else raise the Empty exception ('timeout' is ignored in that case). is#'timeout' must be a positive numberf0.0N(R RRRRRRRRR R!R"R#t_getR%RR&R(R RRR%R#R"((Rtgetes0             cCs |itƒS(s«Remove and return an item from the queue without blocking. Only get an item if one is immediately available. Otherwise raise the Empty exception. N(R R+R((R ((Rt get_nowait‡scCs||_tƒ|_dS(N(R R tdequetqueue(R R ((RR ”s cCs t|iƒS(N(tlenR R.(R ((RR˜scCs|i S(N(R R.(R ((RRœscCs&|idjot|iƒ|ijS(Ni(R R R/R.(R ((RR scCs|ii|ƒdS(N(R R.tappendR%(R R%((RR$€scCs |iiƒS(N(R R.tpopleft(R ((RR*¨s(RRRRRRtTrueRR'R)R+R,R RRRR$R*(((RRs    ! "     N( RttimeR!t collectionsR-t__all__t ExceptionRRR(R-RR5RR!R((Rt?s