[Twisted-Python] txdlo - a Twisted DeferredListObserver
![](https://secure.gravatar.com/avatar/c8f4d4d1a8fc53c13ed05c202e0257fe.jpg?s=120&d=mm&r=g)
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). 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. 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. 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 https://github.com/terrycojones/txdlo Terry
![](https://secure.gravatar.com/avatar/c8f4d4d1a8fc53c13ed05c202e0257fe.jpg?s=120&d=mm&r=g)
Hi Hynek
Any chance of adding a license (*cough* MIT *cough*)
Is Apache ok for you? If not, mail me off list and I can do MIT for you.
and putting the whole thing on PyPI?
See https://pypi.python.org/pypi/txdlo I added a proper README, more tests, the license, setup.py etc. See https://github.com/terrycojones/txdlo Terry On Mon, Dec 30, 2013 at 9:37 AM, Hynek Schlawack <hs@ox.cx> wrote:
![](https://secure.gravatar.com/avatar/174e7b0ff60963f821d0b9a4f1a3ef52.jpg?s=120&d=mm&r=g)
Hey Terry, On 30 Dec 2013, at 21:20, Terry Jones wrote:
Apache is just fine for me – I use it for structlog too. I was suggesting MIT because that’s Twisted’s license.
Great, now I can play with it! —h P.S. if I can pester you any further: I’d appreciate a wheel and you can have a more useful PyPI entry by including the README – see <self-promotion> https://hynek.me/articles/sharing-your-labor-of-love-pypi-quick-and-dirty/ </self-promotion>
![](https://secure.gravatar.com/avatar/c8f4d4d1a8fc53c13ed05c202e0257fe.jpg?s=120&d=mm&r=g)
Hi Hynek On Mon, Dec 30, 2013 at 11:54 PM, Hynek Schlawack <hs@ox.cx> wrote:
if I can pester you any further: I’d appreciate a wheel and you can have a more useful PyPI entry
Thanks for your PyPI guide, it's great. I updated to include a wheel. I tried about 5 different ways to get it to install package data (README, LICENSE), and failed on every attempt (I actually made this work once in the distant past, after several hours of reading and trying). [Rant suppressed.] I'd appreciate any further thoughts/tips re setup.py, but maybe they're better off list. Terry
![](https://secure.gravatar.com/avatar/c8f4d4d1a8fc53c13ed05c202e0257fe.jpg?s=120&d=mm&r=g)
Hi Hynek
Any chance of adding a license (*cough* MIT *cough*)
Is Apache ok for you? If not, mail me off list and I can do MIT for you.
and putting the whole thing on PyPI?
See https://pypi.python.org/pypi/txdlo I added a proper README, more tests, the license, setup.py etc. See https://github.com/terrycojones/txdlo Terry On Mon, Dec 30, 2013 at 9:37 AM, Hynek Schlawack <hs@ox.cx> wrote:
![](https://secure.gravatar.com/avatar/174e7b0ff60963f821d0b9a4f1a3ef52.jpg?s=120&d=mm&r=g)
Hey Terry, On 30 Dec 2013, at 21:20, Terry Jones wrote:
Apache is just fine for me – I use it for structlog too. I was suggesting MIT because that’s Twisted’s license.
Great, now I can play with it! —h P.S. if I can pester you any further: I’d appreciate a wheel and you can have a more useful PyPI entry by including the README – see <self-promotion> https://hynek.me/articles/sharing-your-labor-of-love-pypi-quick-and-dirty/ </self-promotion>
![](https://secure.gravatar.com/avatar/c8f4d4d1a8fc53c13ed05c202e0257fe.jpg?s=120&d=mm&r=g)
Hi Hynek On Mon, Dec 30, 2013 at 11:54 PM, Hynek Schlawack <hs@ox.cx> wrote:
if I can pester you any further: I’d appreciate a wheel and you can have a more useful PyPI entry
Thanks for your PyPI guide, it's great. I updated to include a wheel. I tried about 5 different ways to get it to install package data (README, LICENSE), and failed on every attempt (I actually made this work once in the distant past, after several hours of reading and trying). [Rant suppressed.] I'd appreciate any further thoughts/tips re setup.py, but maybe they're better off list. Terry
participants (2)
-
Hynek Schlawack
-
Terry Jones