Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/Queue.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@s�dZddlmZyddlZWnek
rEddlZnXddlmZddl	Z	ddddd	gZ
defd
��YZdefd��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/sys/lib/python2.7/Queue.pyR
scBseZdZRS(s4Exception raised by Queue.put(block=0)/put_nowait().(RRR	(((s/sys/lib/python2.7/Queue.pyRscBs�eZdZdd�Zd�Zd�Zd�Zd�Zd�Ze	dd�Zd	�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/sys/lib/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/sys/lib/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/sys/lib/python2.7/Queue.pytjoinFs
	
cCs*|jj�|j�}|jj�|S(s9Return the approximate size of the queue (not reliable!).(RRt_qsizeR(Rtn((s/sys/lib/python2.7/Queue.pytqsizeVs

cCs+|jj�|j�}|jj�|S(sCReturn True if the queue is empty, False otherwise (not reliable!).(RRRR(RR((s/sys/lib/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/sys/lib/python2.7/Queue.pytfullds
%
cCs6|jj�z|jdkr�sF|j�|jkr��q�|dkr~x�|j�|jkrz|jj�qUWq�dkr�td��q��|}xN|j�|jkr�t�}|dkr��n|jj|�q�Wn|j	|�|j
d7_
|jj�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/sys/lib/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/sys/lib/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 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/sys/lib/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/sys/lib/python2.7/Queue.pyt
get_nowait�scCst�|_dS(N(Rtqueue(RR
((s/sys/lib/python2.7/Queue.pyR�scCs
||j�S(N(R2(Rtlen((s/sys/lib/python2.7/Queue.pyR�scCs|jj|�dS(N(R2tappend(RR'((s/sys/lib/python2.7/Queue.pyR%�scCs
|jj�S(N(R2tpopleft(R((s/sys/lib/python2.7/Queue.pyR/�sN(RRR	RRRR R!R"tTrueR#R,R.R0R1RR3RR%R/(((s/sys/lib/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/sys/lib/python2.7/Queue.pyR�scCs
||j�S(N(R2(RR3((s/sys/lib/python2.7/Queue.pyR�scCs||j|�dS(N(R2(RR'theappush((s/sys/lib/python2.7/Queue.pyR%�scCs
||j�S(N(R2(Rtheappop((s/sys/lib/python2.7/Queue.pyR/�s(RRR	RR3RtheapqR7R%R8R/(((s/sys/lib/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/sys/lib/python2.7/Queue.pyR�scCs
||j�S(N(R2(RR3((s/sys/lib/python2.7/Queue.pyR�scCs|jj|�dS(N(R2R4(RR'((s/sys/lib/python2.7/Queue.pyR%�scCs
|jj�S(N(R2tpop(R((s/sys/lib/python2.7/Queue.pyR/�s(RRR	RR3RR%R/(((s/sys/lib/python2.7/Queue.pyR�s
		((R	RR$t	threadingRtImportErrortdummy_threadingtcollectionsRR9t__all__t	ExceptionRRRRR(((s/sys/lib/python2.7/Queue.pyt<module>s
�

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].