Files
Home-AssistantConfig/deps/sqlalchemy/util/__pycache__/queue.cpython-34.pyc

63 lines
6.0 KiB
Plaintext
Raw Normal View History

2016-10-11 16:42:06 +00:00
<EFBFBD>
}<7D><>W<EFBFBD><00>@s<>dZddlmZddlmZddlmZdddgZGd d<00>de<00>Z Gd
d<00>de<00>Z
Gd d<00>d<00>Z d S) a<>An adaptation of Py2.3/2.4's Queue module which supports reentrant
behavior, using RLock instead of Lock for its mutex object. The
Queue object is used exclusively by the sqlalchemy.pool.QueuePool
class.
This is to support the connection pool's usage of weakref callbacks to return
connections to the underlying Queue, which can in extremely
rare cases be invoked within the ``get()`` method of the Queue itself,
producing a ``put()`` inside the ``get()`` and therefore a reentrant
condition.
<EFBFBD>)<01>deque)<01>time<6D>)<01> threading<6E>Empty<74>Full<6C>Queuec@seZdZdZdS)rz4Exception raised by Queue.get(block=0)/get_nowait().N)<04>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__<5F>r r <00>;/tmp/pip-build-zkr322cu/sqlalchemy/sqlalchemy/util/queue.pyrs c@seZdZdZdS)rz4Exception raised by Queue.put(block=0)/put_nowait().N)r r
r r r r r rr#s c@s<>eZdZddd<00>Zdd<00>Zdd<00>Zdd <00>Zd
d d d <00>Zdd<00>Zd
d dd<00>Z dd<00>Z
dd<00>Z dd<00>Z dd<00>Z dd<00>Zdd<00>Zdd<00>Zd S) rrcCsJ|j|<00>tj<00>|_tj|j<00>|_tj|j<00>|_dS)zxInitialize a queue object with a given maximum size.
If `maxsize` is <= 0, the queue size is infinite.
N)<07>_initr<00>RLock<63>mutex<65> Condition<6F> not_empty<74>not_full)<02>self<6C>maxsizer r r<00>__init__*s zQueue.__init__cCs*|jj<00>|j<00>}|jj<00>|S)z9Return the approximate size of the queue (not reliable!).)r<00>acquire<72>_qsize<7A>release)r<00>nr r r<00>qsize=s   z Queue.qsizecCs*|jj<00>|j<00>}|jj<00>|S)zKReturn True if the queue is empty, False otherwise (not
reliable!).)rr<00>_emptyr)rrr r r<00>emptyEs   z Queue.emptycCs*|jj<00>|j<00>}|jj<00>|S)zJReturn True if the queue is full, False otherwise (not
reliable!).)rr<00>_fullr)rrr r r<00>fullNs   z
Queue.fullTNc
Cs<>|jj<00>z<>|s.|j<00>r<>t<00>q<>n<>|dkr]x<>|j<00>rY|jj<00>q=Wnm|dkrxtd<00><00>nt<00>|}xB|j<00>r<>|t<00>}|dkr<>t<00>n|jj|<00>q<>W|j|<00>|jj <00>Wd|jj
<00>XdS)aPut 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).
Nrz#'timeout' must be a positive numberg) rrrr<00>wait<69>
ValueError<EFBFBD>_time<6D>_putr<00>notifyr)r<00>item<65>block<63>timeout<75>endtime<6D> remainingr r r<00>putWs&          z Queue.putcCs|j|d<00>S)z<>Put an item into the queue without blocking.
Only enqueue the item if a free slot is immediately available.
Otherwise raise the ``Full`` exception.
F)r+)rr&r r r<00>
put_nowaitzszQueue.put_nowaitc
Cs<>|jj<00>z<>|s.|j<00>r<>t<00>q<>n<>|dkr]x<>|j<00>rY|jj<00>q=Wnm|dkrxtd<00><00>nt<00>|}xB|j<00>r<>|t<00>}|dkr<>t<00>n|jj|<00>q<>W|j<00>}|jj <00>|SWd|jj
<00>XdS)a Remove 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).
Nrz#'timeout' must be a positive numberg) rrrrr!r"r#<00>_getrr%r)rr'r(r)r*r&r r r<00>get<65>s(           z Queue.getcCs |jd<00>S)z<>Remove and return an item from the queue without blocking.
Only get an item if one is immediately available. Otherwise
raise the ``Empty`` exception.
F)r.)rr r r<00>
get_nowait<EFBFBD>szQueue.get_nowaitcCs||_t<00>|_dS)N)rr<00>queue)rrr r rr<00>s z Queue._initcCs t|j<00>S)N)<02>lenr0)rr r rr<00>sz Queue._qsizecCs|j S)N)r0)rr r rr<00>sz Queue._emptycCs%|jdko$t|j<00>|jkS)Nr)rr1r0)rr r rr<00>sz Queue._fullcCs|jj|<00>dS)N)r0<00>append)rr&r r rr$<00>sz
Queue._putcCs |jj<00>S)N)r0<00>popleft)rr r rr-<00>sz
Queue._get)r r
r rrrr r+r,r.r/rrrrr$r-r r r rr)s   # "      N) r <00> collectionsrrr#<00>compatr<00>__all__<5F> Exceptionrrrr r r r<00><module>s