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

remove caching for enabled plugins #1013

Merged
merged 2 commits into from
Aug 3, 2023
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
17 changes: 1 addition & 16 deletions ephios/core/plugins.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import functools
import logging

from django.apps import AppConfig, apps
from django.conf import settings
from django.dispatch import Signal, receiver
from django.dispatch import Signal
from dynamic_preferences.registries import global_preferences_registry
from dynamic_preferences.signals import preference_updated

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -44,7 +42,6 @@ def get_enabled_plugins():
)


@functools.lru_cache()
def is_receiver_path_enabled(searchpath):
"""
Return True only if ``searchpath`` (e.g. 'ephios.plugins.basesignup.signals')
Expand All @@ -64,18 +61,6 @@ def is_receiver_path_enabled(searchpath):
return False


@receiver(preference_updated, dispatch_uid="ephios.core.plugins.clear_receiver_path_cache")
def clear_receiver_path_cache(sender, **kwargs):
from ephios.core.dynamic_preferences_registry import EnabledPlugins

if kwargs.get("name") == EnabledPlugins.name:
logger.debug(
"Resetting plugin path cache. Now enabled: %s",
", ".join(str(plugin.name) for plugin in get_enabled_plugins()),
)
is_receiver_path_enabled.cache_clear()


class PluginSignal(Signal):
"""
Signal that will only be send out to enabled plugins and ephios core.
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def enable_plugins():
preferences["general__enabled_plugins"] = [
plugin.module for plugin in plugins.get_all_plugins()
]
plugins.is_receiver_path_enabled.cache_clear()


@pytest.fixture
Expand Down