class DeferredList(Deferred[
Constructor: DeferredList(deferredList, fireOnOneCallback, fireOnOneErrback, consumeErrors)
DeferredList
is a tool for collecting the results of several Deferreds.
This tracks a list of Deferred
s for their results, and makes a single callback when they have all completed. By default, the ultimate result is a list of (success, result) tuples, 'success' being a boolean. DeferredList
exposes the same API that Deferred
does, so callbacks and errbacks can be added to it in the same way.
DeferredList
is implemented by adding callbacks and errbacks to each Deferred
in the list passed to it. This means callbacks and errbacks added to the Deferreds before they are passed to DeferredList
will change the result that DeferredList
sees (i.e., DeferredList
is not special). Callbacks and errbacks can also be added to the Deferreds after they are passed to DeferredList
and DeferredList
may change the result that they see.
See the documentation for the __init__ arguments for more information.
Method | __init__ |
Initialize a DeferredList. |
Method | cancel |
Cancel this DeferredList . |
Instance Variable | consume |
Undocumented |
Instance Variable | finished |
Undocumented |
Instance Variable | fire |
Undocumented |
Instance Variable | fire |
Undocumented |
Instance Variable | result |
The final result, in progress. Each item in the list corresponds to the Deferred at the same position in _deferredList . It will be None if the Deferred did not complete yet, or a (success, result) pair if it did. |
Method | _cb |
(internal) Callback for when one of my deferreds fires. |
Instance Variable | _deferred |
The list of Deferred s to track. |
Inherited from Deferred
:
Class Method | from |
Schedule the execution of a coroutine that awaits on Deferred s, wrapping it in a Deferred that will fire on success/failure of the coroutine. |
Class Method | from |
Adapt a Future to a Deferred . |
Method | __init |
Undocumented |
Method | __iter__ |
Undocumented |
Method | __str__ |
Return a string representation of this Deferred . |
Method | add |
Convenience method for adding a single callable as both a callback and an errback. |
Method | add |
Convenience method for adding just a callback. |
Method | add |
Add a pair of callbacks (success and error) to this Deferred . |
Method | add |
Convenience method for adding just an errback. |
Method | add |
Time out this Deferred by scheduling it to be cancelled after timeout seconds. |
Method | as |
Adapt this Deferred into a Future which is bound to loop. |
Method | callback |
Run all success callbacks that have been added to this Deferred . |
Method | chain |
Chain another Deferred to this Deferred . |
Method | errback |
Run all error callbacks that have been added to this Deferred . |
Method | pause |
Stop processing on a Deferred until unpause () is called. |
Method | unpause |
Process all callbacks made since pause () was called. |
Class Variable | debug |
Undocumented |
Instance Variable | callbacks |
Undocumented |
Instance Variable | called |
A flag which is False until either callback or errback is called and afterwards always True. |
Instance Variable | paused |
A counter of how many unmatched pause calls have been made on this instance. |
Instance Variable | result |
Undocumented |
Method | _continuation |
Build a tuple of callback and errback with _Sentinel._CONTINUE . |
Method | _run |
Run the chain of callbacks once a result is available. |
Method | _start |
Undocumented |
Instance Variable | _canceller |
Undocumented |
Instance Variable | _chained |
If this Deferred is waiting for the result of another Deferred , this is a reference to the other Deferred. Otherwise, None . |
Instance Variable | _debug |
Undocumented |
Instance Variable | _running |
A flag which is True while this instance is executing its callback chain, used to stop recursive execution of _runCallbacks |
Instance Variable | _suppress |
A flag used by the cancellation mechanism which is True if the Deferred has no canceller and has been cancelled, False otherwise. If True, it can be expected that callback or errback will eventually be called and the result should be silently discarded. |
Iterable[ Deferred[ _SelfResultT]]
, fireOnOneCallback: bool
= False, fireOnOneErrback: bool
= False, consumeErrors: bool
= False):
(source)
¶
twisted.internet.defer.Deferred.__init__
Initialize a DeferredList.
Parameters | |
deferredIterable[ | The deferreds to track. |
firebool | (keyword param) a flag indicating that this DeferredList will fire when the first Deferred in deferredList fires with a non-failure result without waiting for any of the other Deferreds. When this flag is set, the DeferredList will fire with a two-tuple: the first element is the result of the Deferred which fired; the second element is the index in deferredList of that Deferred. |
firebool | (keyword param) a flag indicating that this DeferredList will fire when the first Deferred in deferredList fires with a failure result without waiting for any of the other Deferreds. When this flag is set, if a Deferred in the list errbacks, the DeferredList will errback with a FirstError failure wrapping the failure of that Deferred. |
consumebool | (keyword param) a flag indicating that failures in any of the included Deferred s should not be propagated to errbacks added to the individual Deferred s after this DeferredList is constructed. After constructing the DeferredList , any errors in the individual Deferred s will be converted to a callback result of None . This is useful to prevent spurious 'Unhandled error in Deferred' messages from being logged. This does not prevent fireOnOneErrback from working. |
twisted.internet.defer.Deferred.cancel
Cancel this DeferredList
.
If the DeferredList
hasn't fired yet, cancel every Deferred
in the list.
If the DeferredList
has fired, including the case where the fireOnOneCallback/fireOnOneErrback flag is set and the DeferredList
fires because one Deferred
in the list fires with a non-failure/failure result, do nothing in the cancel method.
The final result, in progress. Each item in the list corresponds to the Deferred
at the same position in _deferredList
. It will be None
if the Deferred
did not complete yet, or a (success, result) pair if it did.
_SelfResultT
, index: int
, succeeded: bool
) -> Optional[ _SelfResultT]
:
(source)
¶
(internal) Callback for when one of my deferreds fires.