From febe3c4bac4dd6e705ef48d97107bd6de82c7cd8 Mon Sep 17 00:00:00 2001 From: Lonami Date: Tue, 30 Apr 2019 20:34:05 +0200 Subject: [PATCH] Be more careful when unloading plugin --- uniborg/uniborg.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/uniborg/uniborg.py b/uniborg/uniborg.py index 0d556b4..77b3406 100644 --- a/uniborg/uniborg.py +++ b/uniborg/uniborg.py @@ -82,9 +82,12 @@ class Uniborg(TelegramClient): plugin = self._plugins.pop(shortname) if callable(getattr(plugin, 'unload', None)): - unload = plugin.unload() - if inspect.isawaitable(unload): - await unload + try: + unload = plugin.unload() + if inspect.isawaitable(unload): + await unload + except Exception: + self._logger.exception(f'Unhandled exception unloading {shortname}') del plugin self._logger.info(f"Removed plugin {shortname}")