<br><br><div class="gmail_quote">On Tue, Jun 26, 2012 at 5:47 AM, Martin <span dir="ltr"><<a href="mailto:martin@webscio.net" target="_blank">martin@webscio.net</a>></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>
> On 25/06/2012, at 10:16 PM, Martin <<a href="mailto:martin@webscio.net">martin@webscio.net</a>> wrote:<br>
><br>
>> On 14/06/12 12:38, Martin wrote:<br>
>>> Hi, thanks for your reply.<br>
>>><br>
>>> Indeed, the ReconnectingClientFactory is being sent the Failure object to<br>
>>><br>
>>> def clientConnectionLost(self, connector, reason):<br>
>>> log.msg('Lost connection. Reason: %s' % reason)<br>
>>> protocol.ReconnectingClientFactory.clientConnectionLost(self,<br>
>>> connector, reason)<br>
>>><br>
>>> where "reason" is the Failure object that is "unhandled". is there<br>
>>> anything I could do to it there to make it handled?<br>
>>><br>
>>> Also, the documentation in<br>
>>> <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>
>>> that one can do d.addErrback(err.log) to deal with unhandled errors,<br>
>>> but what is d?<br>
>>><br>
>>> In general, I'm not doing anything special.. I'm creating a<br>
>>> ReconnectingClientFactory and connecting it to a server..<br>
>>> f = MyReconnectingClientFactory(..)<br>
>>> reactor.connectSSL(url, port, f, ssl.ClientContextFactory())<br>
>>> reactor.run()<br>
>>><br>
>>> Basically it. Any thoughts? Thanks a lot!<br>
>>>> On Jun 11, 2012, at 8:01 AM, Martin wrote:<br>
>>>><br>
>>>>> Hi there,<br>
>>>>><br>
>>>>> I've been looking around for a solution for several hours now, and<br>
>>>>> maybe<br>
>>>>> I'm just missing something..<br>
>>>>><br>
>>>>> I've a factory that implements protocol.ReconnectingClientFactory which<br>
>>>>> works just fine, however, whenever the program ends running, I get a<br>
>>>>> bunch of Unhandled error in Deferred messages in my log for each<br>
>>>>> disconnection that occurred during runtime, such as Failure:<br>
>>>>> twisted.internet.error.ConnectionLost: ...<br>
>>>>><br>
>>>>> Is there any way I could somehow "handle" these during runtime, so that<br>
>>>>> my log wouldn't be spammed with this at the end.. (or avoid it being<br>
>>>>> spammed somehow..)<br>
>>>> These messages are coming from some code which is issuing Deferreds,<br>
>>>> not from ReconnectingClientFactory. You need to add an errback to<br>
>>>> those Deferreds in your application code. There's no way to write a<br>
>>>> catch-all, just like there's no way to write a catch-all that can<br>
>>>> stop exceptions from being raised in basic Python.<br>
>>>><br>
>>>> I can't say more without a code example, preferably<br>
>>>> a<<a href="http://sscce.org/" target="_blank">http://sscce.org/</a>>.<br>
>>>><br>
>>>> -glyph<br>
>>>><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>
>>>><br>
>>>><br>
>> No suggestions as to how I could get rid of this? :(<br>
>><br>
>><br>
> 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't want to see anything out of them, simply don't print anything.<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>
> _______________________________________________<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>
><br>
><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't know though is<br>
how am I supposed to catch these deferreds - that is not being explained<br>
anywhere in the documentation I'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'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 & elegant.</div>
<div><br></div><div>Regards</div><div><br></div><div>gelin yan</div>