[Twisted-Python] Re: Wrapping functions that return deferreds
Ross Burton
ross at burtonini.com
Wed Apr 11 07:35:10 MDT 2007
On Wed, 2007-04-11 at 12:05 +0200, Antoine Pitrou wrote:
> Le mercredi 11 avril 2007 à 10:42 +0100, Ross Burton a écrit :
> > def wrap_deferred (func):
> > def wrapped(*args, **kwargs):
> > d = func (*args, **kwargs)
> > d.addErrback (handle_twisted_error)
> > return d
> > return wrapped
> >
> > # flickr is the object, call is the method I'm overriding
> > flickr.call = wrap_deferred (flickr.call)
> >
> > # Then later in my app
> > flickr.call(foo).addCallback(handleFoo)
>
> Since you add the errback before adding the callback, errors happening
> in handleFoo will not get caught by the errback.
That is fine -- handleFoo doesn't throw any errors. The deferred
returned by the original call() is calling errBack().
Ross
--
Ross Burton mail: ross at burtonini.com
jabber: ross at burtonini.com
www: http://www.burtonini.com./
PGP Fingerprint: 1A21 F5B0 D8D0 CFE3 81D4 E25A 2D09 E447 D0B4 33DF
More information about the Twisted-Python
mailing list