[Twisted-Python] Catching error in protocol.ReconnectingClientFactory

Martin martin at webscio.net
Mon Jun 25 08:16:30 EDT 2012

On 14/06/12 12:38, Martin wrote:
> Hi, thanks for your reply.
> Indeed, the ReconnectingClientFactory is being sent the Failure object to
> def clientConnectionLost(self, connector, reason):
>         log.msg('Lost connection. Reason: %s' % reason)
> protocol.ReconnectingClientFactory.clientConnectionLost(self, 
> connector, reason)
> where "reason" is the Failure object that is "unhandled". is there 
> anything I could do to it there to make it handled?
> Also, the documentation in 
> http://twistedmatrix.com/documents/current/core/howto/defer.html says 
> that one can do d.addErrback(err.log) to deal with unhandled errors, 
> but what is d?
> In general, I'm not doing anything special.. I'm creating a 
> ReconnectingClientFactory and connecting it to a server..
> f = MyReconnectingClientFactory(..)
> reactor.connectSSL(url, port, f, ssl.ClientContextFactory())
> reactor.run()
> Basically it. Any thoughts? Thanks a lot!
>> On Jun 11, 2012, at 8:01 AM, Martin wrote:
>>> Hi there,
>>> I've been looking around for a solution for several hours now, and 
>>> maybe
>>> I'm just missing something..
>>> I've a factory that implements protocol.ReconnectingClientFactory which
>>> works just fine, however, whenever the program ends running, I get a
>>> bunch of Unhandled error in Deferred messages in my log for each
>>> disconnection that occurred during runtime, such as Failure:
>>> twisted.internet.error.ConnectionLost: ...
>>> Is there any way I could somehow "handle" these during runtime, so that
>>> my log wouldn't be spammed with this at the end.. (or avoid it being
>>> spammed somehow..)
>> These messages are coming from some code which is issuing Deferreds, 
>> not from ReconnectingClientFactory.  You need to add an errback to 
>> those Deferreds in your application code.  There's no way to write a 
>> catch-all, just like there's no way to write a catch-all that can 
>> stop exceptions from being raised in basic Python.
>> I can't say more without a code example, preferably 
>> a<http://sscce.org/>.
>> -glyph
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
No suggestions as to how I could get rid of this? :(

More information about the Twisted-Python mailing list