usr/lib64/python2.7/Queue.pyo000064400000022320147204477260011676 0ustar00 zfc@sdZddlmZyddlZWnek rEddlZnXddlmZddl Z ddddd gZ de fd YZ de fd YZ ddd YZdefd YZd efdYZdS(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.pyRscBseZdZddZdZdZdZdZdZe ddZ d Z e dd Z d Zd Zed ZdZdZRS(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|jjzQ|jd}|dkrT|dkrDtdn|jjn||_Wd|jjXdS(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|jjz!x|jr,|jjqWWd|jjXdS(sBlocks 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|jjd|jko-|jkn}|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|jjz|jdkr|sF|j|jkrtqq|dkr~x|j|jkrz|jjqUWq|dkrtdqt|}xN|j|jkr|t}|dkrtn|jj|qWn|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 non-negative 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 non-negative numbergiN(RRR RRtNoneRRt_timet_putRRtnotifyR(Rtitemtblockttimeouttendtimet remaining((s/usr/lib64/python2.7/Queue.pytputks*         cCs|j|tS(sPut 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_nowaitscCs|jjz|s.|jstqn|dkr]x|jsY|jjq=Wnm|dkrxtdnRt|}xB|js|t}|dkrtn|jj|qW|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 non-negative 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 non-negative numbergN( RRRRR#RRR$t_getRR&R(RR(R)R*R+R'((s/usr/lib64/python2.7/Queue.pytgets(           cCs |jtS(sRemove 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_nowaitscCst|_dS(N(Rtqueue(RR ((s/usr/lib64/python2.7/Queue.pyR scCs ||jS(N(R2(Rtlen((s/usr/lib64/python2.7/Queue.pyRscCs|jj|dS(N(R2tappend(RR'((s/usr/lib64/python2.7/Queue.pyR%scCs |jjS(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      # "   cBsAeZdZdZedZejdZej dZ RS(sVariant 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 ||jS(N(R2(RR3((s/usr/lib64/python2.7/Queue.pyRscCs||j|dS(N(R2(RR'theappush((s/usr/lib64/python2.7/Queue.pyR%scCs ||jS(N(R2(Rtheappop((s/usr/lib64/python2.7/Queue.pyR/s( RRR R R3RtheapqR7R%R8R/(((s/usr/lib64/python2.7/Queue.pyRs   cBs5eZdZdZedZdZdZRS(sBVariant of Queue that retrieves most recently added entries first.cCs g|_dS(N(R2(RR ((s/usr/lib64/python2.7/Queue.pyR scCs ||jS(N(R2(RR3((s/usr/lib64/python2.7/Queue.pyRscCs|jj|dS(N(R2R4(RR'((s/usr/lib64/python2.7/Queue.pyR%scCs |jjS(N(R2tpop(R((s/usr/lib64/python2.7/Queue.pyR/s(RRR R R3RR%R/(((s/usr/lib64/python2.7/Queue.pyRs    ((R RR$t threadingR t ImportErrortdummy_threadingt collectionsRR9t__all__t ExceptionRRRRR(((s/usr/lib64/python2.7/Queue.pyts