Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevents duplicate loading of plugins #2490

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions glue/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def load_plugins(splash=None, require_qt_plugins=False, plugins_to_load=None):
config = PluginConfig.load()

if plugins_to_load is None:
plugins_to_load = [i.value for i in list(iter_plugin_entry_points())]
plugins_to_load = [i.module for i in list(iter_plugin_entry_points())]
if require_qt_plugins:
plugins_to_require = [*REQUIRED_PLUGINS, *REQUIRED_PLUGINS_QT]
else:
Expand All @@ -59,7 +59,8 @@ def load_plugins(splash=None, require_qt_plugins=False, plugins_to_load=None):
n_plugins = len(plugins_to_require)

for i_plugin, item in enumerate(list(iter_plugin_entry_points())):
if item.value.replace(':setup', '') in plugins_to_load:

if item.module in plugins_to_load:
if item.module not in _installed_plugins:
_installed_plugins.add(item.name)

Expand Down
20 changes: 20 additions & 0 deletions glue/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from unittest.mock import patch

from glue.main import load_plugins


def test_no_duplicate_loading(capsys):
"""
Regression test for duplicated loading of plugins
on subsequent calls of `load_plugins()` after initial
glue-qt startup.

"""
from glue.logger import logger

with patch.object(logger, 'info') as info:
load_plugins()

for acall in info.call_args_list:
if 'Loading plugin' in acall[0][0]:
assert 'failed' in acall[0][0]
Loading