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 __init__(self, allowZombies=False):
Undocumented
@contextmanager
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>
def acquire(self, vip=False):

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.

def acquireAndRelease(self, vip=False):

Acquires the lock and immediately releases it.

def release(self):

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.

def addStopper(self, f, *args, **kw):

Add a callable (along with any args and kw) to be run when shutting things down.

The callable may return a deferred, and more than one can be added. They will be called, and their result awaited, in the order received.

def stop(self):

Shut things down, when the waiting list empties.

API Documentation for AsynQueue, generated by pydoctor at 2022-11-17 13:13:24.