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