From 775eb0a0f2244de7da6c1593edb9f0f97fd79dd4 Mon Sep 17 00:00:00 2001 From: Jason Bruce Date: Thu, 29 Apr 2021 15:08:53 -0400 Subject: [PATCH] fixing divide by zero bug when thermocouple read fails five times in a row --- lib/oven.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/oven.py b/lib/oven.py index 4a1f5b0..5d0f0ef 100644 --- a/lib/oven.py +++ b/lib/oven.py @@ -128,7 +128,8 @@ class TempSensorReal(TempSensor): except Exception: log.exception("problem reading temp") time.sleep(sleeptime) - self.temperature = sum(temps)/len(temps) + if len(temps) > 0: + self.temperature = sum(temps)/len(temps) class Oven(threading.Thread): '''parent oven class. this has all the common code