[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 Mar 6 14:31:24 UTC 2017


Hello Holger Freyther,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1920

to look at the new patch set (#3).

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/3

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 @@
 
     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: newpatchset
Gerrit-Change-Id: Ib7b0e45fa1f5551da2fc81b71dcc227eee533f44
Gerrit-PatchSet: 3
Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list