Be more careful when unloading plugin

master
Lonami 2019-04-30 20:34:05 +02:00
parent c8b5179cb5
commit febe3c4bac
1 changed files with 6 additions and 3 deletions

View File

@ -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}")