From 5cda671c66f87e437260b946be9c2d8d65a05207 Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Thu, 12 Aug 2021 16:43:06 +0200 Subject: [PATCH] L2SS-333: CommClient.connect now does not return, but raises an exception upon failure. This replaces using 'return True' and raising an exception. --- devices/clients/comms_client.py | 6 +++++- devices/test/clients/test_client.py | 6 +----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/devices/clients/comms_client.py b/devices/clients/comms_client.py index 6aa52ae42..2aa9c661f 100644 --- a/devices/clients/comms_client.py +++ b/devices/clients/comms_client.py @@ -35,7 +35,11 @@ class CommClient(Thread): def run(self): # Explicitly connect - if not self.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 diff --git a/devices/test/clients/test_client.py b/devices/test/clients/test_client.py index 355b4f72a..c8e564ca7 100644 --- a/devices/test/clients/test_client.py +++ b/devices/test/clients/test_client.py @@ -21,10 +21,7 @@ class test_client(CommClient): super().__init__(fault_func, streams, try_interval) # Explicitly connect - if not self.connect(): - # hardware or infra is down -- needs fixing first - fault_func() - return + self.connect() def connect(self): """ @@ -33,7 +30,6 @@ class test_client(CommClient): self.streams.debug_stream("the example client doesn't actually connect to anything silly") self.connected = True # set connected to true - return True # if succesfull, return true. otherwise return false def disconnect(self): self.connected = False # always force a reconnect, regardless of a successful disconnect -- GitLab