Take the 2-minute tour ×

I'm using twisted manhole (https://github.com/HoverHell/pyaux/blob/master/pyaux/runlib.py#L126), and I also send errors caught by Twisted into python logging (https://github.com/HoverHell/pyaux/blob/master/pyaux/twisted_aux.py#L9).

However, as a result, the log gets ConnectionDone() errors, which isn't a very interesting thing as an error.

What would be appropriate to change to avoid getting this (and, possibly, some other) not-exactly-errors? Filtering for twisted.python.failure.Failure cases, perhaps? And where from is the ConnectionDone() even raised and why?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

ConnectionDone() instance is given to connectionLost() callback after the connection has been closed. You should be seeing this, when the client side decides to close the connection. You definitely don't want to filter the Failure out. You can think of the failure as a "asynchronous analogy" of the Exception. The usual thing to do, not to see some kind of exceptions is something like:

from twisted.internet import error


def connectionLost(self, reason):
    if reason.check(error.ConnectionDone):
        # this is normal, ignore this
        # do whatever you have been doing for logging
share|improve this answer
Is ConnectionDone the only such special case, or there are some others? –  HoverHell Jan 27 '13 at 3:23
There is also ConnectionLost is used when connection is closed in non-clean manner. These are used by twisted itself for all the protocols. Reason may also be somethign specific to the protocol you are using, this depends on the implementation itself. –  Marek Kowalski Jan 27 '13 at 12:14
It's error, though, not errors. Anyway, subclassing TelnetTransport with that helps; but really, I can't imagine the reason for the twistedmatrix.com/trac/browser/trunk/twisted/conch/… part (options processing on connectionLost? huh) –  HoverHell Jan 29 '13 at 9:26
Options is not the perfect choice of the variable name there... They represent the effect of negotiation. Depending on that, each side of the connection might be or not notified about the connection termination. This is what that code is doing... I've seen much worse. –  Marek Kowalski Jan 29 '13 at 9:51
add comment

Your Answer


