FIX: Use a separate error handler for the Pushbullet backend that doesn't raise another exception (prevents maximum recursion errors in the logs caused by the interpreter entering an infinite loop of error handlers)

This commit is contained in:
Fabio Manganiello 2022-01-08 19:52:41 +01:00
parent 833e1c49be
commit a6b552504e
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -135,6 +135,20 @@ class PushbulletBackend(Backend):
return callback return callback
def on_error(self, *_):
def callback(*args):
self.logger.error(f'Pushbullet error: {args}')
try:
if self.listener:
self.listener.close()
except Exception as e:
self.logger.error('Error on Pushbullet connection close upon error')
self.logger.exception(e)
finally:
self.listener = None
return callback
def on_open(self): def on_open(self):
def callback(*_): def callback(*_):
self.logger.info('Pushbullet service connected') self.logger.info('Pushbullet service connected')
@ -149,7 +163,7 @@ class PushbulletBackend(Backend):
on_push=self.on_push(), on_push=self.on_push(),
on_open=self.on_open(), on_open=self.on_open(),
on_close=self.on_close(), on_close=self.on_close(),
on_error=self.on_close(), on_error=self.on_error(),
http_proxy_host=self.proxy_host, http_proxy_host=self.proxy_host,
http_proxy_port=self.proxy_port) http_proxy_port=self.proxy_port)