t.i.d.DeferredSemaphore(_ConcurrencyPrimitive) : class documentation

Part of twisted.internet.defer View Source View In Hierarchy

A semaphore for event driven systems.
Instance Variable tokens At most this many users may acquire this semaphore at once. (type: int)
Instance Variable limit The difference between tokens and the number of users which have currently acquired this semaphore. (type: int)
Method __init__ Undocumented
Method acquire Attempt to acquire the token.
Method release Release the token.
Method _cancelAcquire Remove a deferred d from our waiting list, as the deferred has been canceled.

Inherited from _ConcurrencyPrimitive:

Method run Acquire, run, release.
Method _releaseAndReturn Undocumented
tokens =
At most this many users may acquire this semaphore at once. (type: int)
limit =
The difference between tokens and the number of users which have currently acquired this semaphore. (type: int)
def __init__(self, tokens): (source)
Undocumented
def _cancelAcquire(self, d): (source)
Remove a deferred d from our waiting list, as the deferred has been canceled.

Note: We do not need to wrap this in a try/except to catch d not being in self.waiting because this canceller will not be called if d has fired. release() pops a deferred out of self.waiting and calls it, so the canceller will no longer be called.

ParametersdThe deferred that has been canceled.
def acquire(self): (source)
Attempt to acquire the token.
Returnsa Deferred which fires on token acquisition.
def release(self): (source)
Release the token.

Should be called by whoever did the acquire() when the shared resource is free.

API Documentation for Twisted, generated by pydoctor at 2012-06-04 17:20:01.