From 792b3e8d0a32facaf2638158b4ce6d24be5f122d Mon Sep 17 00:00:00 2001 From: Nico Melone Date: Thu, 8 Sep 2022 17:48:34 -0500 Subject: [PATCH] added try/catch --- .DS_Store | Bin 16388 -> 16388 bytes tankalarms/tankalarms.py | 41 +++++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.DS_Store b/.DS_Store index a59178cb2b203c0c56b7c5d3d64f9d80269dad0b..337388e57778ee1b07d55595f7ed784d8e37ae94 100644 GIT binary patch delta 169 zcmZo^U~Fk%oZ!zGu`ysbKcoEQw*qpTwFKU>FfvY-5S_!5R9;+=l#`#tz`(F;@&>&^ zO{wZ?BLfo)9R*VplUf~xYC}UaOC1Gs1B=>PP7YCJee0n3?3~=Z{GQ1T!t#v0lP8E8 zOb!-RVlS delta 76 zcmZo^U~Fk%oZ!zGx-nokKcnpAw*qpTwFKU>FfvS*5S=r5o*2*OTVjTs8yln;88s&J eC}?l?QP|Hvu|ae*x4|{`$=}qKH?vsW1v3E8D;f9z diff --git a/tankalarms/tankalarms.py b/tankalarms/tankalarms.py index 1c46b05..64fc400 100644 --- a/tankalarms/tankalarms.py +++ b/tankalarms/tankalarms.py @@ -69,28 +69,31 @@ class start(threading.Thread, deviceBase): send_loops = 0 while True: - now = time.time() - if self.force_send: - log.warning("FORCE SEND: TRUE") + try: + now = time.time() + if self.force_send: + log.warning("FORCE SEND: TRUE") - for chan in CHANNELS: - val = chan.read() - if chan.check(val, self.force_send): - self.sendtodbDev(1, chan.mesh_name, chan.value, 0, 'tankalarms') - time.sleep(TAG_DATAERROR_SLEEPTIME) # sleep to allow Micro800 to handle ENET requests + for chan in CHANNELS: + val = chan.read() + if chan.check(val, self.force_send): + self.sendtodbDev(1, chan.mesh_name, chan.value, 0, 'tankalarms') + time.sleep(TAG_DATAERROR_SLEEPTIME) # sleep to allow Micro800 to handle ENET requests - # print("tankalarms driver still alive...") - if self.force_send: - if send_loops > 2: - log.warning("Turning off force_send") - self.force_send = False - send_loops = 0 - else: - send_loops += 1 + # print("tankalarms driver still alive...") + if self.force_send: + if send_loops > 2: + log.warning("Turning off force_send") + self.force_send = False + send_loops = 0 + else: + send_loops += 1 - - if (now - self.public_ip_address_last_checked) > IP_CHECK_PERIOD: - self._check_ip_address() + + if (now - self.public_ip_address_last_checked) > IP_CHECK_PERIOD: + self._check_ip_address() + except Exception as e: + log.error(e) def _check_ip_address(self):