From a6b552504e2ac327c94f3a28b607061b6b60cf36 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 8 Jan 2022 19:52:41 +0100 Subject: [PATCH] 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) --- platypush/backend/pushbullet/__init__.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/platypush/backend/pushbullet/__init__.py b/platypush/backend/pushbullet/__init__.py index 7d0b21b87..71f26db70 100644 --- a/platypush/backend/pushbullet/__init__.py +++ b/platypush/backend/pushbullet/__init__.py @@ -135,6 +135,20 @@ class PushbulletBackend(Backend): 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 callback(*_): self.logger.info('Pushbullet service connected') @@ -149,7 +163,7 @@ class PushbulletBackend(Backend): on_push=self.on_push(), on_open=self.on_open(), on_close=self.on_close(), - on_error=self.on_close(), + on_error=self.on_error(), http_proxy_host=self.proxy_host, http_proxy_port=self.proxy_port)