<br><br><div class="gmail_quote">On Tue, Jun 26, 2012 at 5:47 AM, Martin <span dir="ltr">&lt;<a href="mailto:martin@webscio.net" target="_blank">martin@webscio.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 25/06/12 22:27, Adrian Overbury wrote:<br>
&gt; On 25/06/2012, at 10:16 PM, Martin &lt;<a href="mailto:martin@webscio.net">martin@webscio.net</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; On 14/06/12 12:38, Martin wrote:<br>
&gt;&gt;&gt; Hi, thanks for your reply.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Indeed, the ReconnectingClientFactory is being sent the Failure object to<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; def clientConnectionLost(self, connector, reason):<br>
&gt;&gt;&gt;         log.msg(&#39;Lost connection. Reason: %s&#39; % reason)<br>
&gt;&gt;&gt; protocol.ReconnectingClientFactory.clientConnectionLost(self,<br>
&gt;&gt;&gt; connector, reason)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; where &quot;reason&quot; is the Failure object that is &quot;unhandled&quot;. is there<br>
&gt;&gt;&gt; anything I could do to it there to make it handled?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Also, the documentation in<br>
&gt;&gt;&gt; <a href="http://twistedmatrix.com/documents/current/core/howto/defer.html" target="_blank">http://twistedmatrix.com/documents/current/core/howto/defer.html</a> says<br>
&gt;&gt;&gt; that one can do d.addErrback(err.log) to deal with unhandled errors,<br>
&gt;&gt;&gt; but what is d?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; In general, I&#39;m not doing anything special.. I&#39;m creating a<br>
&gt;&gt;&gt; ReconnectingClientFactory and connecting it to a server..<br>
&gt;&gt;&gt; f = MyReconnectingClientFactory(..)<br>
&gt;&gt;&gt; reactor.connectSSL(url, port, f, ssl.ClientContextFactory())<br>
&gt;&gt;&gt; reactor.run()<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Basically it. Any thoughts? Thanks a lot!<br>
&gt;&gt;&gt;&gt; On Jun 11, 2012, at 8:01 AM, Martin wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Hi there,<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I&#39;ve been looking around for a solution for several hours now, and<br>
&gt;&gt;&gt;&gt;&gt; maybe<br>
&gt;&gt;&gt;&gt;&gt; I&#39;m just missing something..<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I&#39;ve a factory that implements protocol.ReconnectingClientFactory which<br>
&gt;&gt;&gt;&gt;&gt; works just fine, however, whenever the program ends running, I get a<br>
&gt;&gt;&gt;&gt;&gt; bunch of Unhandled error in Deferred messages in my log for each<br>
&gt;&gt;&gt;&gt;&gt; disconnection that occurred during runtime, such as Failure:<br>
&gt;&gt;&gt;&gt;&gt; twisted.internet.error.ConnectionLost: ...<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Is there any way I could somehow &quot;handle&quot; these during runtime, so that<br>
&gt;&gt;&gt;&gt;&gt; my log wouldn&#39;t be spammed with this at the end.. (or avoid it being<br>
&gt;&gt;&gt;&gt;&gt; spammed somehow..)<br>
&gt;&gt;&gt;&gt; These messages are coming from some code which is issuing Deferreds,<br>
&gt;&gt;&gt;&gt; not from ReconnectingClientFactory.  You need to add an errback to<br>
&gt;&gt;&gt;&gt; those Deferreds in your application code.  There&#39;s no way to write a<br>
&gt;&gt;&gt;&gt; catch-all, just like there&#39;s no way to write a catch-all that can<br>
&gt;&gt;&gt;&gt; stop exceptions from being raised in basic Python.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I can&#39;t say more without a code example, preferably<br>
&gt;&gt;&gt;&gt; a&lt;<a href="http://sscce.org/" target="_blank">http://sscce.org/</a>&gt;.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; -glyph<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; Twisted-Python mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
&gt;&gt;&gt;&gt; <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt; No suggestions as to how I could get rid of this? :(<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt; I believe glyph gave you the answer to that already.  In your example above of d.addErrBack, d is the deferred object.  Each of those needs to have an errback handler attached to it.  If you don&#39;t want to see anything out of them, simply don&#39;t print anything.<br>

&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Twisted-Python mailing list<br>
&gt;&gt; <a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
&gt;&gt; <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
&gt; _______________________________________________<br>
&gt; Twisted-Python mailing list<br>
&gt; <a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
&gt; <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
&gt;<br>
&gt;<br>
</div></div>Well, kind of - I know that I need to do addErrBack on the deferred<br>
objects, I kind of knew that when I asked the original question having<br>
read the documentation on deferreds. What I still don&#39;t know though is<br>
how am I supposed to catch these deferreds - that is not being explained<br>
anywhere in the documentation I&#39;m afraid.<br>
<div class="HOEnZb"><div class="h5"><br>
<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><div>Hi</div><div>   Usually you don&#39;t need to catch a deferred object..adding some callbacks is enough..</div><div><br></div><div>I admit it might not be intuitive to understand defer concept at your first trial. But it is powerful &amp; elegant.</div>
<div><br></div><div>Regards</div><div><br></div><div>gelin yan</div>