class documentation

class DeferredQueue(Generic[_T]): (source)

View In Hierarchy

An event driven queue.

Objects may be added as usual to this queue. When an attempt is made to retrieve an object when the queue is empty, a Deferred is returned which will fire when an object becomes available.

Method __init__ Undocumented
Method get Attempt to retrieve and remove an object from the queue.
Method put Add an object to this queue.
Instance Variable backlog The maximum number of Deferred gets to allow at one time. When an attempt is made to get an object which would exceed this limit, QueueUnderflow is raised synchronously. None for no limit.
Instance Variable pending Undocumented
Instance Variable size The maximum number of objects to allow into the queue at a time. When an attempt to add a new object would exceed this limit, QueueOverflow is raised synchronously. None for no limit.
Instance Variable waiting Undocumented
Method _cancelGet Remove a deferred d from our waiting list, as the deferred has been canceled.
def __init__(self, size=None, backlog=None): (source)

Undocumented

Parameters
size:Optional[int]Undocumented
backlog:Optional[int]Undocumented
def get(self): (source)
Attempt to retrieve and remove an object from the queue.
Returns
Deferred[_T]a Deferred which fires with the next object available in the queue.
Raises
QueueUnderflowToo many (more than backlog) Deferreds are already waiting for an object from this queue.
def put(self, obj): (source)
Add an object to this queue.
Parameters
obj:_TUndocumented
Raises
QueueOverflowToo many objects are in this queue.
backlog = (source)
The maximum number of Deferred gets to allow at one time. When an attempt is made to get an object which would exceed this limit, QueueUnderflow is raised synchronously. None for no limit.
pending: List[_T] = (source)

Undocumented

size = (source)
The maximum number of objects to allow into the queue at a time. When an attempt to add a new object would exceed this limit, QueueOverflow is raised synchronously. None for no limit.
waiting: List[Deferred[_T]] = (source)

Undocumented

def _cancelGet(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. put() pops a deferred out of self.waiting and calls it, so the canceller will no longer be called.

Parameters
d:Deferred[object]The deferred that has been canceled.