From 8e9f30f3e12b59d2a432bd0306f08a9825d42f5e Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 27 Feb 2017 01:17:22 +0100 Subject: [PATCH] tcp_debug: don't abort when socket can't be removed It appears that during some error conditions, the socket will not be in the tcp socket debug tracking list, and on top of an exception this barfs as well. Let's not care about the tcp debug list and avoid confusing error messages. Change-Id: I8daa317fed8fc7e720dccb70fd5f7fc74fde423f --- osmopy/obscvty.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index bbf6e45..f5c85fb 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -74,7 +74,10 @@ class VTYInteract(object): return if debug_tcp_sockets: - VTYInteract.all_sockets.remove(self.socket) + try: + VTYInteract.all_sockets.remove(self.socket) + except ValueError: + pass print "Socket: closing %s:%d %r (%d sockets open)" % ( self.host, self.port, self.socket, len(VTYInteract.all_sockets))