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
2012-06-14 12:28:51+0100 [-] Unhandled error in Deferred:
2012-06-14 12:28:51+0100 [-] Unhandled Error
Traceback (most recent call last):
Failure: twisted.internet.error.ConnectionLost: Connection to the other side was lost in a non-clean fashion: Connection lost.
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..) I really don’t care what the solution is, I already have the following method that logs everything for me
def clientConnectionLost(self, connector, reason):
log.msg('Lost connection. Reason: %s' % reason)
is there anything I could do with the “reason” in there, which is the Failure object, so that the error would be properly handled..?
Anyway, I don’t claim to be anywhere near proficient in Twisted, so any help would be greatly appreciated.
Thanks a lot in advance.
The message
Unhandled error in Deferredis telling you where the error comes from and even hinting at how to eliminate it. When aDeferredis garbage collected with aFailureresult, it logs these messages – because the error wasn’t handled.Add an error handler (and errback) to the
Deferredthat fails this way, and handle the error however you want (including ignoring it, if that’s what’s appropriate for your application).