Implemented retry mechanism in sensor backend

This commit is contained in:
Fabio Manganiello 2020-02-26 11:12:46 +01:00
parent 76800e00b1
commit 52a13f0511
1 changed files with 19 additions and 8 deletions

View File

@ -82,8 +82,19 @@ class SensorBackend(Backend):
if not self.plugin:
raise NotImplementedError('No plugin specified')
plugin = get_plugin(self.plugin)
reload = False
success = False
data = None
while not success:
try:
plugin = get_plugin(self.plugin, reload=reload)
data = plugin.get_data(**self.plugin_args).output
except Exception as e:
self.logger.warning('Unexpected exception while getting data: {}'.format(str(e)))
self.logger.exception(e)
reload = True
time.sleep(5)
if self.enabled_sensors:
data = {