From 9112239ac3aa2346cc84f3fa025df1e3e65c3ef2 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 19 Feb 2023 23:03:27 +0100 Subject: [PATCH] Better exception management in `AsyncRunnablePlugin`. Exceptions that cause the termination of the plugin's loop should always be logged as such, unless the plugin is supposed to stop and various exceptions may occur upon teardown. --- platypush/plugins/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/__init__.py b/platypush/plugins/__init__.py index ea271cd2d..9db52b021 100644 --- a/platypush/plugins/__init__.py +++ b/platypush/plugins/__init__.py @@ -212,7 +212,9 @@ class AsyncRunnablePlugin(RunnablePlugin, ABC): try: self._loop.run_until_complete(self._task) except Exception as e: - self.logger.info('The loop has terminated with an error: %s', e) + if not self.should_stop(): + self.logger.warning('The loop has terminated with an error') + self.logger.exception(e) self._task.cancel()