ó m”þfc@sædZddlmZyddlZWnek rEddlZnXddlmZddl Z ddddd gZ de fd „ƒYZ de fd „ƒYZ ddd „ƒYZdefd „ƒYZd efd„ƒYZdS(s'A multi-producer, multi-consumer queue.iÿÿÿÿ(ttimeN(tdequetEmptytFulltQueuet PriorityQueuet LifoQueuecBseZdZRS(s4Exception raised by Queue.get(block=0)/get_nowait().(t__name__t __module__t__doc__(((s/usr/lib64/python2.7/Queue.pyR scBseZdZRS(s4Exception raised by Queue.put(block=0)/put_nowait().(RRR (((s/usr/lib64/python2.7/Queue.pyRscBsžeZdZdd„Zd„Zd„Zd„Zd„Zd„Ze dd„Z d „Z e dd „Z d „Zd „Zed „Zd„Zd„ZRS(sjCreate a queue object with a given maximum size. If maxsize is <= 0, the queue size is infinite. icCsq||_|j|ƒtjƒ|_tj|jƒ|_tj|jƒ|_tj|jƒ|_d|_ dS(Ni( tmaxsizet_initt _threadingtLocktmutext Conditiont not_emptytnot_fulltall_tasks_donetunfinished_tasks(tselfR ((s/usr/lib64/python2.7/Queue.pyt__init__s  cCss|jjƒzQ|jd}|dkrT|dkrDtdƒ‚n|jjƒn||_Wd|jjƒXdS(s.Indicate that a formerly enqueued task is complete. Used by Queue consumer threads. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises a ValueError if called more times than there were items placed in the queue. iis!task_done() called too many timesN(RtacquireRt ValueErrort notify_alltrelease(Rt unfinished((s/usr/lib64/python2.7/Queue.pyt task_done-s     cCsC|jjƒz!x|jr,|jjƒqWWd|jjƒXdS(sƒBlocks until all items in the Queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer thread calls task_done() to indicate the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. N(RRRtwaitR(R((s/usr/lib64/python2.7/Queue.pytjoinFs  cCs*|jjƒ|jƒ}|jjƒ|S(s9Return the approximate size of the queue (not reliable!).(RRt_qsizeR(Rtn((s/usr/lib64/python2.7/Queue.pytqsizeVs   cCs+|jjƒ|jƒ }|jjƒ|S(sCReturn True if the queue is empty, False otherwise (not reliable!).(RRRR(RR((s/usr/lib64/python2.7/Queue.pytempty]s   cCsC|jjƒd|jko-|jƒkn}|jjƒ|S(sBReturn True if the queue is full, False otherwise (not reliable!).i(RRR RR(RR((s/usr/lib64/python2.7/Queue.pytfullds % cCs6|jjƒz|jdkr÷|sF|jƒ|jkrôt‚qôq÷|dkr~xŸ|jƒ|jkrz|jjƒqUWq÷|dkr™tdƒ‚q÷tƒ|}xN|jƒ|jkró|tƒ}|dkràt‚n|jj|ƒq©Wn|j |ƒ|j d7_ |j j ƒWd|jj ƒ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 numbergiN(RRR RRtNoneRRt_timet_putRRtnotifyR(Rtitemtblockttimeouttendtimet remaining((s/usr/lib64/python2.7/Queue.pytputks*         cCs|j|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. (R,tFalse(RR'((s/usr/lib64/python2.7/Queue.pyt put_nowaitŽscCsý|jjƒzÛ|s.|jƒsÊt‚qÊnœ|dkr]x|jƒsY|jjƒq=Wnm|dkrxtdƒ‚nRtƒ|}xB|jƒsÉ|tƒ}|dkr¶t‚n|jj|ƒqˆW|jƒ}|j j ƒ|SWd|jj ƒ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 numbergN( RRRRR#RRR$t_getRR&R(RR(R)R*R+R'((s/usr/lib64/python2.7/Queue.pytget–s(           cCs |jtƒ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. (R0R-(R((s/usr/lib64/python2.7/Queue.pyt get_nowait¸scCstƒ|_dS(N(Rtqueue(RR ((s/usr/lib64/python2.7/Queue.pyR ÅscCs ||jƒS(N(R2(Rtlen((s/usr/lib64/python2.7/Queue.pyRÈscCs|jj|ƒdS(N(R2tappend(RR'((s/usr/lib64/python2.7/Queue.pyR%ÌscCs |jjƒS(N(R2tpopleft(R((s/usr/lib64/python2.7/Queue.pyR/ÐsN(RRR RRRR R!R"tTrueR#R,R.R0R1R R3RR%R/(((s/usr/lib64/python2.7/Queue.pyRs      # "   cBsAeZdZd„Zed„Zejd„Zej d„Z RS(sœVariant of Queue that retrieves open entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cCs g|_dS(N(R2(RR ((s/usr/lib64/python2.7/Queue.pyR ÚscCs ||jƒS(N(R2(RR3((s/usr/lib64/python2.7/Queue.pyRÝscCs||j|ƒdS(N(R2(RR'theappush((s/usr/lib64/python2.7/Queue.pyR%àscCs ||jƒS(N(R2(Rtheappop((s/usr/lib64/python2.7/Queue.pyR/ãs( RRR R R3RtheapqR7R%R8R/(((s/usr/lib64/python2.7/Queue.pyRÔs   cBs5eZdZd„Zed„Zd„Zd„ZRS(sBVariant of Queue that retrieves most recently added entries first.cCs g|_dS(N(R2(RR ((s/usr/lib64/python2.7/Queue.pyR êscCs ||jƒS(N(R2(RR3((s/usr/lib64/python2.7/Queue.pyRíscCs|jj|ƒdS(N(R2R4(RR'((s/usr/lib64/python2.7/Queue.pyR%ðscCs |jjƒS(N(R2tpop(R((s/usr/lib64/python2.7/Queue.pyR/ós(RRR R R3RR%R/(((s/usr/lib64/python2.7/Queue.pyRçs    ((R RR$t threadingR t ImportErrortdummy_threadingt collectionsRR9t__all__t ExceptionRRRRR(((s/usr/lib64/python2.7/Queue.pyts  ¿