aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-02-27 01:12:14 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-03-06 15:31:08 +0100
commite34932099218d7b8c4e00629242551edced2e2fb (patch)
treeed51b0b682dce199b9cdccc2632dd1b73ef6a96c
parentcb320b8ddf91037872b0fe47a2b8f8d5ac26da4f (diff)
cosmetic: early exit instead of if-cascade
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: Ib7b0e45fa1f5551da2fc81b71dcc227eee533f44
-rwxr-xr-xosmopy/obscvty.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py
index f614518..bbf6e45 100755
--- a/osmopy/obscvty.py
+++ b/osmopy/obscvty.py
@@ -70,14 +70,16 @@ class VTYInteract(object):
def _close_socket(self):
global debug_tcp_sockets
- if self.socket:
- if debug_tcp_sockets:
- VTYInteract.all_sockets.remove(self.socket)
- print "Socket: closing %s:%d %r (%d sockets open)" % (
- self.host, self.port, self.socket,
- len(VTYInteract.all_sockets))
- self.socket.close()
- self.socket = None
+ if self.socket is None:
+ return
+
+ if debug_tcp_sockets:
+ VTYInteract.all_sockets.remove(self.socket)
+ print "Socket: closing %s:%d %r (%d sockets open)" % (
+ self.host, self.port, self.socket,
+ len(VTYInteract.all_sockets))
+ self.socket.close()
+ self.socket = None
def _is_end(self, text, ends):
"""