From 0dbe3ae8f7362a422c14b410b0cedb0ed536230e Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Thu, 12 Aug 2021 17:06:54 +0200
Subject: [PATCH] L2SS-333: Initial connect is duplicated by retrying to
 connect, so removed the former. Also, don't check the return value of
 connect() anymore but deal with the exception instead.

---
 devices/clients/comms_client.py | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/devices/clients/comms_client.py b/devices/clients/comms_client.py
index 2aa9c661f..b204dfb65 100644
--- a/devices/clients/comms_client.py
+++ b/devices/clients/comms_client.py
@@ -33,26 +33,15 @@ class CommClient(Thread):
         self.connected = False
 
     def run(self):
-
-        # Explicitly connect
-        try:
-            self.connect():
-        except Exception as e:
-            self.streams.error_stream("Fault condition in communication detected.", e)
-
-            # hardware or infra is down -- needs fixing first
-            self.fault_func()
-            return
-
         self.stopping = False
         while not self.stopping:
-            # keep trying to connect
             if not self.connected:
-                if self.connect():
-                    pass
-                else:
-                    # we retry only once, to catch exotic network issues. if the infra or hardware is down,
-                    # our device cannot help, and must be reinitialised after the infra or hardware is fixed.
+                # we (re)try only once, to catch exotic network issues. if the infra or hardware is down,
+                # our device cannot help, and must be reinitialised after the infra or hardware is fixed.
+                try:
+                    self.connect()
+                except Exception as e:
+                    self.streams.error_stream("Fault condition in communication detected.", e)
                     self.fault_func()
                     return
 
-- 
GitLab