On 03:33 pm, te...@jon.es wrote: >Is there a reason why the Deferred class doesn't have a tee method like >the >following (untested)? > > def tee(self, d): > def _cb(arg): > d.callback(arg) > return arg > > def _eb(arg): > d.errback(arg) > return arg > > return self.addCallbacks(_cb, _eb) > >I suppose it could be called teeDeferred to correspond to >chainDeferred. >And I guess it's clear what it does and why it's quite different from >chainDeferred. I at least would find it quite useful.
We implemented this 5 or 6 times at Divmod. The most recent incarnation looks like this: http://divmod.org/trac/browser/trunk/Epsilon/epsilon/pending.py I admit that I'd probably find it about as useful as I find explicit calls to Deferred.chainDeferred - perhaps even slightly more so. Though that's a low bar, I can't remember the last time I explicitly called chainDeferred; it's probably been a couple years. Not to say it's a bad idea, but I don't think it's _obviously_ a great idea. If someone wanted to contribute a documented, tested implementation, particularly with examples of common patterns that it simplifies, then you could probably convince someone to commit it. Jean-Paul _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python