Skip to content
Snippets Groups Projects
Commit 0dbe3ae8 authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-333: Initial connect is duplicated by retrying to connect, so removed the...

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.
parent 5cda671c
No related branches found
No related tags found
1 merge request!95L2SS-333: Improve CommClient.connect signature
...@@ -33,26 +33,15 @@ class CommClient(Thread): ...@@ -33,26 +33,15 @@ class CommClient(Thread):
self.connected = False self.connected = False
def run(self): 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 self.stopping = False
while not self.stopping: while not self.stopping:
# keep trying to connect
if not self.connected: if not self.connected:
if self.connect(): # we (re)try only once, to catch exotic network issues. if the infra or hardware is down,
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. # 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() self.fault_func()
return return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment