Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / eventlet / semaphore.pyc
Size: Mime:
ó
 ‹EYc@snddlZddlZddlmZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(	iÿÿÿÿN(thubst	SemaphorecBsƒeZdZdd„Zd„Zd„Zd„Zd„Zed
d„Z
d„Zed	„Zd
„Z
d„Zed„ƒZRS(sžAn unbounded semaphore.
    Optionally initialize with a resource *count*, then :meth:`acquire` and
    :meth:`release` resources as needed. Attempting to :meth:`acquire` when
    *count* is zero suspends the calling greenthread until *count* becomes
    nonzero again.

    This is API-compatible with :class:`threading.Semaphore`.

    It is a context manager, and thus can be used in a with block::

      sem = Semaphore(2)
      with sem:
        do_some_stuff()

    If not specified, *value* defaults to 1.

    It is possible to limit acquire time::

      sem = Semaphore()
      ok = sem.acquire(timeout=0.1)
      # True if acquired, False if timed out.

    icCsœyt|ƒ}Wn=tk
rO}djt|ƒt|ƒƒ}t|ƒ‚nX|dkr€djt|ƒƒ}t|ƒ‚n||_tj	ƒ|_
dS(Ns0Semaphore() expect value :: int, actual: {0} {1}is*Semaphore() expect value >= 0, actual: {0}(tintt
ValueErrortformatttypetstrt	TypeErrortreprtcountertcollectionstdequet_waiters(tselftvaluetetmsg((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyt__init__!s	cCs8|jjtt|ƒƒ|jt|jƒf}d|S(Ns<%s at %s c=%s _w[%s]>(t	__class__t__name__thextidR	tlenR(R
tparams((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyt__repr__-scCs)|jj|jt|jƒf}d|S(Ns<%s c=%s _w[%s]>(RRR	RR(R
R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyt__str__2s!cCs
|jdkS(s7Returns true if a call to acquire would block.
        i(R	(R
((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pytlocked6scCstS(sbReturns False; for consistency with
        :class:`~eventlet.semaphore.CappedSemaphore`.
        (tFalse(R
((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pytbounded;scCs|dkrd}n|dk	r<|dkr<tdƒ‚n|sf|dk	r]tdƒ‚nd}n|r}|jƒr}tStjƒ}|jdks¡|jrŠ||jkrÃ|jj|ƒnz˜|dk	r*t}tj	|tƒ1x#|jdkrt
jƒjƒqîWt
}WdQX|sZtSn0x-t
rYt
jƒjƒ|jdkr-Pq-q-WWdy|jj|ƒWntk
r…nXXn|jd8_t
S(sAcquire a semaphore.

        When invoked without arguments: if the internal counter is larger than
        zero on entry, decrement it by one and return immediately. If it is zero
        on entry, block, waiting until some other thread has called release() to
        make it larger than zero. This is done with proper interlocking so that
        if multiple acquire() calls are blocked, release() will wake exactly one
        of them up. The implementation may pick one at random, so the order in
        which blocked threads are awakened should not be relied on. There is no
        return value in this case.

        When invoked with blocking set to true, do the same thing as when called
        without arguments, and return true.

        When invoked with blocking set to false, do not block. If a call without
        an argument would block, return false immediately; otherwise, do the
        same thing as when called without arguments, and return true.

        Timeout value must be strictly positive.
        iÿÿÿÿis'timeout value must be strictly positives.can't specify timeout for non-blocking acquireNi(tNoneRRRteventlett
getcurrentR	RtappendtTimeoutRtget_hubtswitchtTruetremove(R
tblockingttimeouttcurrent_threadtok((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pytacquireAsB			
cCs|jƒdS(N(R*(R
((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyt	__enter__€scCs8|jd7_|jr4tjƒjd|jƒntS(s-Release a semaphore, incrementing the internal counter by one. When
        it was zero on entry and another thread is waiting for it to become
        larger than zero again, wake up that thread.

        The *blocking* argument is for consistency with CappedSemaphore and is
        ignored
        ii(R	RRR"tschedule_call_globalt_do_acquireR$(R
R&((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pytreleaseƒs	cCs8|jr4|jdkr4|jjƒ}|jƒndS(Ni(RR	tpopleftR#(R
twaiter((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyR-scCs|jƒdS(N(R.(R
ttyptvalttb((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyt__exit__•scCs|jt|jƒS(sPAn integer value that represents how many new calls to
        :meth:`acquire` or :meth:`release` would be needed to get the counter to
        0.  If it is positive, then its value is the number of acquires that can
        happen before the next acquire would block.  If it is negative, it is
        the negative of the number of releases that would be required in order
        to make the counter 0 again (one more release would push the counter to
        1 and unblock acquirers).  It takes into account how many greenthreads
        are currently blocking in :meth:`acquire`.
        (R	RR(R
((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pytbalance˜sN(Rt
__module__t__doc__RRRRRR$RR*R+R.R-R4tpropertyR5(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyRs				?	
		tBoundedSemaphorecBs&eZdZdd„Zed„ZRS(sJA bounded semaphore checks to make sure its current value doesn't exceed
    its initial value. If it does, ValueError is raised. In most situations
    semaphores are used to guard resources with limited capacity. If the
    semaphore is released too many times it's a sign of a bug. If not given,
    *value* defaults to 1.
    icCs#tt|ƒj|ƒ||_dS(N(tsuperR9Rtoriginal_counter(R
R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyR²scCs7|j|jkr!tdƒ‚ntt|ƒj|ƒS(sRelease a semaphore, incrementing the internal counter by one. If
        the counter would exceed the initial value, raises ValueError.  When
        it was zero on entry and another thread is waiting for it to become
        larger than zero again, wake up that thread.

        The *blocking* argument is for consistency with :class:`CappedSemaphore`
        and is ignored
        s!Semaphore released too many times(R	R;RR:R9R.(R
R&((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyR.¶s	(RR6R7RR$R.(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyR9©stCappedSemaphorecBsteZdZd„Zd„Zd„Zd„Zd„Zed„Z	d„Z
ed„Zd	„Ze
d
„ƒZRS(s{A blockingly bounded semaphore.

    Optionally initialize with a resource *count*, then :meth:`acquire` and
    :meth:`release` resources as needed. Attempting to :meth:`acquire` when
    *count* is zero suspends the calling greenthread until count becomes nonzero
    again.  Attempting to :meth:`release` after *count* has reached *limit*
    suspends the calling greenthread until *count* becomes less than *limit*
    again.

    This has the same API as :class:`threading.Semaphore`, though its
    semantics and behavior differ subtly due to the upper limit on calls
    to :meth:`release`.  It is **not** compatible with
    :class:`threading.BoundedSemaphore` because it blocks when reaching *limit*
    instead of raising a ValueError.

    It is a context manager, and thus can be used in a with block::

      sem = CappedSemaphore(2)
      with sem:
        do_some_stuff()
    cCs`|dkrtd|ƒ‚n||kr:tdƒ‚nt|ƒ|_t||ƒ|_dS(NisBCappedSemaphore must be initialized with a positive number, got %ss#'count' cannot be more than 'limit'(RRtlower_boundtupper_bound(R
tcounttlimit((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyRÜs
cCs8|jjtt|ƒƒ|j|j|jf}d|S(Ns<%s at %s b=%s l=%s u=%s>(RRRRR5R=R>(R
R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyRæscCs)|jj|j|j|jf}d|S(Ns<%s b=%s l=%s u=%s>(RRR5R=R>(R
R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyRëscCs
|jjƒS(s7Returns true if a call to acquire would block.
        (R=R(R
((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyRðscCs
|jjƒS(s7Returns true if a call to release would block.
        (R>R(R
((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyRõscCsX|r|jƒrtS|jjƒy|jjƒSWn|jjd8_‚nXdS(sÕAcquire a semaphore.

        When invoked without arguments: if the internal counter is larger than
        zero on entry, decrement it by one and return immediately. If it is zero
        on entry, block, waiting until some other thread has called release() to
        make it larger than zero. This is done with proper interlocking so that
        if multiple acquire() calls are blocked, release() will wake exactly one
        of them up. The implementation may pick one at random, so the order in
        which blocked threads are awakened should not be relied on. There is no
        return value in this case.

        When invoked with blocking set to true, do the same thing as when called
        without arguments, and return true.

        When invoked with blocking set to false, do not block. If a call without
        an argument would block, return false immediately; otherwise, do the
        same thing as when called without arguments, and return true.
        iN(RRR>R.R=R*R	(R
R&((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyR*ús
cCs|jƒdS(N(R*(R
((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyR+scCsX|r|jƒrtS|jjƒy|jjƒSWn|jjd8_‚nXdS(sORelease a semaphore.  In this class, this behaves very much like
        an :meth:`acquire` but in the opposite direction.

        Imagine the docs of :meth:`acquire` here, but with every direction
        reversed.  When calling this method, it will block if the internal
        counter is greater than or equal to *limit*.
        iN(RRR=R.R>R*R	(R
R&((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyR.s
cCs|jƒdS(N(R.(R
R1R2R3((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyR4-scCs|jj|jjS(sdAn integer value that represents how many new calls to
        :meth:`acquire` or :meth:`release` would be needed to get the counter to
        0.  If it is positive, then its value is the number of acquires that can
        happen before the next acquire would block.  If it is negative, it is
        the negative of the number of releases that would be required in order
        to make the counter 0 again (one more release would push the counter to
        1 and unblock acquirers).  It takes into account how many greenthreads
        are currently blocking in :meth:`acquire` and :meth:`release`.
        (R=R5R>(R
((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyR50s(RR6R7RRRRRR$R*R+R.R4R8R5(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyR<Äs	
						(R
RRtobjectRR9R<(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/semaphore.pyt<module>s
¢