<div dir="ltr">I just wrote a quick class called DeferredListObserver that lets you do various things with a list of deferreds. You can add observers that get passed information about the deferreds firing. You can also add deferreds to the observed list at any time (this is very useful if you're dynamically creating deferreds that you want to monitor).<div>
<br></div><div>The class can be used to easily build things like Twisted's DeferredList or simple variants of it, or can let you separate the various behaviors of DeferredList into simpler functions. You can also do other things that I've occasionally wanted.  E.g., get a deferred that fires when N of the observed deferreds have fired. Or ignore errors until one deferred succeeds, only firing with an error if all deferreds fail. Or write a DeferredPool with a notifyWhenEmpty method like the one I posted here about 4 years ago.</div>
<div><br></div><div>Or (a more involved example), suppose you have 3 methods that can return you a user's avatar: a fast local cache, a filesystem, and a slow network call to Gravatar. You want to launch all three lookups at once and use the first answer. But if the cache and/or filesystems fails first, you don't want an error you instead want to take the result from Gravatar and add it to the cache and/or filesystem, as well firing a deferred with the result (wherever it comes from). Only if all three lookups fail do you want to receive an error.</div>
<div><br></div><div>I'll improve the examples (and probably add tests for them) at some point. Meanwhile, the DeferredListObserver class (in txdlo.py), tests for it, and various examples can be had from <a href="https://github.com/terrycojones/txdlo">https://github.com/terrycojones/txdlo</a></div>
<div><br></div><div>Terry</div><div><br></div></div>