That way works, but the original problem was that a failure in one of them was stopping the whole callback chain.
Missing from my example (but present in a past example) was a try/except around the yield keyword. So: ... try: yield deferred1 except: pass ... try: yield deferred2 except: pass would swallow any exceptions thrown by deferred1 and continue on to create deferred2. If you did: d.addCallback(foo) d.addCallback(bar) d.addCallback(baz) then an exception in "foo" would break the whole callback chain. - Matt On Thu, Sep 17, 2009 at 3:32 AM, Amaury Forgeot d'Arc <amaur...@gmail.com>wrote: > Hello, > > 2009/9/17 Matt Perry <m...@unshift.net>: > > Make sure you're using the @inlineCallbacks decorator and the yield > > statement referenced previously. Without those you're just adding > several > > callbacks to the same Deferred; with them, the function will wait until > the > > Deferred fires before continuing. > > > > def logRequest(self, *arg, **kw): > > obj = copy.deepcopy(kw['obj']) > > > > d = self.db.runInteraction(obj.first) > > > > d.addCallback(self.db.runInteraction, obj.second, param1, param2) > > d.addErrback(log.err) > > > > d.addCallback(self.db.runInteraction, obj.third) > > d.addErrback(log.err) > > I don't understand your explanation. When a callback returns a Deferred > itself, > the main Deferred object waits for its completion before continuing. > This is IMO the best feature of Deferreds! > > I often write code like the function above, so I would like to understand > why > it does not work in this case. > > -- > Amaury Forgeot d'Arc > > _______________________________________________ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python >
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python