A Twisted class for observing a set of deferreds.
Project description
txdlo is a Python package that provides a class called DeferredListObserver.
As you might guess, DeferredListObserver lets you observe callback and errback events from a list of Twisted deferreds. You can add observers that will be passed information about deferreds firing. You can add deferreds to the observed list at any time, which is very useful if you’re dynamically creating deferreds that you want to monitor.
The class can be used to easily build functions or classes that provide deferreds that fire when arbitrary combinations of events from the observed deferreds have occurred.
For example you can write functions or classes that support deferreds that
Implement Twisted’s DeferredList or simple variants of it, or that let you separate the various behaviors of DeferredList into simpler functions.
Provide a deferred that fires when N of the observed deferreds have fired.
Provide a deferred that ignores errors until one of the observed deferred succeeds, only firing with an error if all the observed deferreds fail.
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 write a deferred-returning function that launches all three lookups at once and fires its deferred with the first answer. But if the cache and/or filesystems fails first, you don’t want to trigger an error, you instead want to take the result from Gravatar and add it to the cache and/or filesystem, as well firing the returned deferred with the result (wherever it comes from). Only if all three lookups fail do you want to errback the deferred you returned.
The source for txdlo lives at https://github.com/terrycojones/txdlo.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file txdlo-0.1.2.tar.gz
.
File metadata
- Download URL: txdlo-0.1.2.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63e4ab2b2ddc74a786e5884aa98c87069cb4402b9caed4d2a74bdc954408d4d4 |
|
MD5 | 761505677b79da38df4d9085648c77fd |
|
BLAKE2b-256 | c06dfb75cdbace16465df4f778a0ceb5458eccbb8b755aa3b3b78b6c66e7e78f |
File details
Details for the file txdlo-0.1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: txdlo-0.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf4813e1d7038185cb9ee54c653512f60d923c042fb5423f7e5937ec44ece345 |
|
MD5 | a3c4186c68c9d28c2ee877c1a1b93a06 |
|
BLAKE2b-256 | 356ca52e76e0d8ed4919be110d44f998450299b1ce7c177aa5d2e4d98c6e0dc3 |