From 78ed83ebf7b0cf83c0ece4abaeaf3697754a6406 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Fri, 1 May 2020 18:45:52 +0200 Subject: [PATCH] Fix plugins not being properly unloaded Also, plugins' roots values will follow python notation: folder.plugins instead of folder/plugins, in case of roots inside another folder. --- pyrogram/client/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 7c2279b9..3ef82ada 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -872,6 +872,7 @@ class Client(Methods, BaseClient): app.stop() """ + def do_it(): self.terminate() self.disconnect() @@ -918,6 +919,7 @@ class Client(Methods, BaseClient): app.stop() """ + def do_it(): self.stop() self.start() @@ -1525,7 +1527,7 @@ class Client(Methods, BaseClient): count = 0 if not include: - for path in sorted(Path(root).rglob("*.py")): + for path in sorted(Path(root.replace(".", "/")).rglob("*.py")): module_path = '.'.join(path.parent.parts + (path.stem,)) module = reload(import_module(module_path)) @@ -1587,7 +1589,7 @@ class Client(Methods, BaseClient): warn_non_existent_functions = True try: - module = reload(import_module(module_path)) + module = import_module(module_path) except ImportError: log.warning('[{}] [UNLOAD] Ignoring non-existent module "{}"'.format( self.session_name, module_path))