[PATCH] python/osmo-python-tests[master]: cosmetic: early exit instead of if-cascade

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Feb 27 01:13:31 UTC 2017


Review at  https://gerrit.osmocom.org/1920

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
---
M osmopy/obscvty.py
1 file changed, 10 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/20/1920/1

diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py
index b09d108..420db7d 100755
--- a/osmopy/obscvty.py
+++ b/osmopy/obscvty.py
@@ -70,14 +70,16 @@
 
     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):
         """

-- 
To view, visit https://gerrit.osmocom.org/1920
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7b0e45fa1f5551da2fc81b71dcc227eee533f44
Gerrit-PatchSet: 1
Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list