Wrap Google Fit checks in try-catch block to prevent the backend from crashing with no reload

This commit is contained in:
Fabio Manganiello 2019-03-20 10:48:07 +00:00
parent 7072a19829
commit 92f1f3eea7

View file

@ -66,6 +66,7 @@ class GoogleFitBackend(Backend):
self.logger.info('Scanning fit data source, last seen timestamp: {}'.
format(str(datetime.datetime.fromtimestamp(last_timestamp))))
try:
for data_source in self.data_sources:
data_source_last_timestamp = 0
data_points = get_plugin('google.fit').get_data(
@ -94,12 +95,16 @@ class GoogleFitBackend(Backend):
self.logger.info('Got {} entries from data source {}, last timestamp: {}'.
format(len(data_points), data_source,
str(datetime.datetime.fromtimestamp(data_source_last_timestamp))))
last_timestamp = new_last_timestamp
get_plugin('variable').set(**{
self._last_timestamp_varname: last_timestamp})
except Exception as e:
self.logger.warning('Exception while processing Fit data')
self.logger.exception(e)
continue
time.sleep(self.poll_seconds)