[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
Thu Mar 2 02:38:15 UTC 2017


cosmetic: early exit instead of if-cascade

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

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



More information about the gerrit-log mailing list