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
This commit is contained in:
Neels Hofmeyr 2017-02-27 01:12:14 +01:00
parent cb320b8ddf
commit e349320992
1 changed files with 10 additions and 8 deletions

View File

@ -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):
"""