From 29585aa33986a926360fca3e95ed9dc708200411 Mon Sep 17 00:00:00 2001 From: emintham Date: Fri, 31 Aug 2018 18:37:24 -0400 Subject: [PATCH] Fix plugins being reloaded each time - Fix plugins being reloaded each time when the path to plugins has __init__ files. - The __init__ files will be found by `self._get_modules` but since they are not plugins, they will never be registered in `self._plugins`. This causes plugins to be reloaded each time. --- yantra/manager.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/yantra/manager.py b/yantra/manager.py index 73bef63..fd63bba 100644 --- a/yantra/manager.py +++ b/yantra/manager.py @@ -59,7 +59,15 @@ def _get_modules(self): def get_plugins(self): """Discover all plugins of the set plugin type in the path""" - modules = self._get_modules() + # ignore __init__ as they are never registered as plugins and + # their inclusion in `modules` will cause `len(modules)` to + # never equal `len(self._plugins)`, thus reloading all plugins + # each time this method is called. + modules = [ + module + for module in self._get_modules() + if module[0] != '__init__' + ] # load plugins again only if a plugin was added or removed if len(modules) == len(self._plugins):