Implemented retry mechanism in sensor backend
This commit is contained in:
parent
76800e00b1
commit
52a13f0511
1 changed files with 19 additions and 8 deletions
|
@ -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 = {
|
||||
|
|
Loading…
Reference in a new issue