[Twisted-Python] deferred proposed update
James Y Knight
foom at fuhm.net
Thu Jan 29 13:48:31 MST 2004
On Jan 29, 2004, at 10:09 AM, Glyph Lefkowitz wrote:
> Fabrice Coudert wrote:
>
>> So, I restate the probleme with chainDeferred :
>> chainDeferred(d) is equivalent to addCallbacks(d.callback, d.errback),
>> but this two methods are not really sort of callback methods for
>> deferred coz they didn't return a result.
>
> This is not a problem, this is a specification of the way it works.
> chainDeferred is a holdover from before one could sensibly return one
> Deferred from the callback to another. If you want to add callbacks
> in some other way, don't use chainDeferred.
So, the right way to do what he asks is...? Perhaps this?
my_defer = getADeferredForSomething()
new_defer = defer.Deferred()
new_defer.addCallback(preprocessing)
new_defer.addCallback(lambda x: return my_defer)
new_defer.addCallback(postprocessing)
my_defer = new_defer
James
More information about the Twisted-Python
mailing list