Add try/catch for client's "read temp" logic

this can isolate an error for a certain probe, so that other probes can go
ahead and take their readings during each client run.  that way only the bad
one is marked as "error" status by the server
This commit is contained in:
Lance Edgar 2018-10-23 17:39:18 -05:00
parent b644818eef
commit 8220082359

View file

@ -137,8 +137,14 @@ class TempmonClient(Daemon):
Take a single reading and add to Rattail database. Take a single reading and add to Rattail database.
""" """
reading = tempmon.Reading() reading = tempmon.Reading()
try:
reading.degrees_f = self.read_temp(probe) reading.degrees_f = self.read_temp(probe)
except:
log.exception("Failed to read temperature (but will keep trying) for probe: %s", probe)
else:
# a reading of 185.0 °F indicates some sort of power issue. when this # a reading of 185.0 °F indicates some sort of power issue. when this
# happens we log an error (which sends basic email) but do not record # happens we log an error (which sends basic email) but do not record
# the temperature. that way the server doesn't see the 185.0 reading # the temperature. that way the server doesn't see the 185.0 reading