diff --git a/devices/clients/comms_client.py b/devices/clients/comms_client.py index 2aa9c661f11c255352b5af412f72b86cb5af32fc..b204dfb6567ef41e589734fe4ff0f3f87dbd2de5 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