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.
This commit is contained in:
Fabio Manganiello 2023-02-19 23:03:27 +01:00
parent a6c36fa1c1
commit 9112239ac3
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
1 changed files with 3 additions and 1 deletions

View File

@ -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()