asynqueue.util.DeferredLock(defer.DeferredLock)
class documentation
Part of asynqueue.util
(View In Hierarchy)
I am a modified form of defer.DeferredLock
lock that lets
you shut things down when you get the lock.
The allowZombies keyword is ignored as the lock's behavior has
been changed to always return an immediate Deferred
from a
call to acquire
if
the lock has been stopped. I mean, why the hell not?
Method | __init__ | Undocumented |
Method | context | Usage example, inside a defer.inlineCallbacks function: |
Method | acquire | Like defer.DeferredLock.acquire except with a vip
option. |
Method | acquireAndRelease | Acquires the lock and immediately releases it. |
Method | release | Acts like Twisted's regular defer.DeferredLock.release
unless I'm stopped. Then calling this does nothing because the lock is
acquired instantly in that condition. |
Method | addStopper | Add a callable (along with any args and kw) to be run when shutting things down. |
Method | stop | Shut things down, when the waiting list empties. |
def context(self, vip=False):
Usage example, inside a defer.inlineCallbacks function:
with lock.context() as d: # "Wait" for the yield d <Do something that requires holding onto the lock> <Proceed with the lock released>
Like defer.DeferredLock.acquire
except with a vip
option.
This lets you cut ahead of everyone in the regular waiting list and gets the next lock, after anyone else in the VIP line who is waiting from their own call of this method.
If I'm stopped, calling this method simply returns an immediate
Deferred
.
Acts like Twisted's regular defer.DeferredLock.release
unless I'm stopped. Then calling this does nothing because the lock is
acquired instantly in that condition.