From f0d92d9ac2b9f49e6b748cbf9608c3aefd06d7f2 Mon Sep 17 00:00:00 2001 From: Wilfred Tyler Gee Date: Fri, 24 May 2024 13:18:01 -1000 Subject: [PATCH] Sensor recording improvement * If the reading thread dies on then the thread dies and doesn't start back up, so just add exception here. --- src/panoptes/pocs/utils/service/power.py | 5 ++++- src/panoptes/pocs/utils/service/weather.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/panoptes/pocs/utils/service/power.py b/src/panoptes/pocs/utils/service/power.py index 26b29a192..2bfe0d26f 100644 --- a/src/panoptes/pocs/utils/service/power.py +++ b/src/panoptes/pocs/utils/service/power.py @@ -44,7 +44,10 @@ def record_readings(): power_board.logger.info(f'Setting up power recording {record_interval=}') while True: time.sleep(record_interval) - power_board.record(collection_name='power') + try: + power_board.record(collection_name='power') + except Exception as e: + power_board.logger.warning(f'Could not get power record: {e}') # Create a thread to record the readings at an interval. power_thread = Thread(target=record_readings) diff --git a/src/panoptes/pocs/utils/service/weather.py b/src/panoptes/pocs/utils/service/weather.py index c25c8a8e2..bccb90cf1 100644 --- a/src/panoptes/pocs/utils/service/weather.py +++ b/src/panoptes/pocs/utils/service/weather.py @@ -54,7 +54,10 @@ def record_readings(): weather_station.logger.info(f'Setting up weather recording {record_interval=}') while True: time.sleep(record_interval) - weather_station.record() + try: + weather_station.record() + except Exception as e: + weather_station.logger.warning(f'Could not get weather record: {e}') # Create a thread to record the readings at an interval weather_thread = Thread(target=record_readings)