ó ÃÌ4]c@sˆdZddlmZddlmZddlmZdddgZdefd „ƒYZ defd „ƒYZ dd d „ƒYZ d S(sð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. iÿÿÿÿ(tdeque(ttimei(t threadingtEmptytFulltQueuecBseZdZRS(s4Exception raised by Queue.get(block=0)/get_nowait().(t__name__t __module__t__doc__(((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyRscBseZdZRS(s4Exception raised by Queue.put(block=0)/put_nowait().(RRR(((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyR$scBs˜eZded„Zd„Zd„Zd„Zedd„Z d„Z edd„Z d„Z d „Z d „Zd „Zd „Zd „Zd„ZRS(icCsS|j|ƒtjƒ|_tj|jƒ|_tj|jƒ|_||_dS(s½Initialize a queue object with a given maximum size. If `maxsize` is <= 0, the queue size is infinite. If `use_lifo` is True, this Queue acts like a Stack (LIFO). N(t_initRtRLocktmutext Conditiont not_emptytnot_fulltuse_lifo(tselftmaxsizeR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyt__init__+s  cCs*|jjƒ|jƒ}|jjƒ|S(s9Return the approximate size of the queue (not reliable!).(R tacquiret_qsizetrelease(Rtn((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pytqsizeBs   cCs*|jjƒ|jƒ}|jjƒ|S(sKReturn True if the queue is empty, False otherwise (not reliable!).(R Rt_emptyR(RR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pytemptyJs   cCs*|jjƒ|jƒ}|jjƒ|S(sJReturn True if the queue is full, False otherwise (not reliable!).(R Rt_fullR(RR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pytfullSs   cCsú|jjƒzØ|s.|jƒrÊt‚qÊnœ|dkr]x|jƒrY|jjƒq=Wnm|dkrxtdƒ‚ntƒ|}xB|jƒrÉ|tƒ}|dkr¶t‚n|jj|ƒqˆW|j|ƒ|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 numbergN( RRRRtNonetwaitt ValueErrort_timet_putR tnotifyR(Rtitemtblockttimeouttendtimet remaining((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pytput\s&          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"((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyt put_nowaitscCsý|jjƒzÛ|s.|jƒrÊt‚qÊnœ|dkr]x|jƒrY|jjƒq=Wnm|dkrxtdƒ‚ntƒ|}xB|jƒrÉ|tƒ}|dkr¶t‚n|jj|ƒqˆW|jƒ}|j j ƒ|SWd|jj ƒXdS(s 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). is#'timeout' must be a positive numbergN( R RRRRRRRt_getRR!R(RR#R$R%R&R"((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/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. (R+R((R((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyt get_nowait©scCs||_tƒ|_dS(N(RRtqueue(RR((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyR ·s cCs t|jƒS(N(tlenR-(R((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyR»scCs|j S(N(R-(R((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyR¿scCs%|jdko$t|jƒ|jkS(Ni(RR.R-(R((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyRÃscCs|jj|ƒdS(N(R-tappend(RR"((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyR ÇscCs'|jr|jjƒS|jjƒSdS(N(RR-tpoptpopleft(R((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyR*Ës  N(RRR(RRRRtTrueRR'R)R+R,R RRRR R*(((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyR*s  # "      N(( Rt collectionsRRRtcompatRt__all__t ExceptionRRR(((sH/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/util/queue.pyts