From 55db0d580dfece8b8d213c2fd353f299003c9c6b Mon Sep 17 00:00:00 2001 From: Muhammad Labeeb Date: Thu, 20 Feb 2025 17:47:17 +0500 Subject: [PATCH] add plugin unload function while disabling plugin --- tutordash/server/app.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tutordash/server/app.py b/tutordash/server/app.py index 09682ef..24a200d 100644 --- a/tutordash/server/app.py +++ b/tutordash/server/app.py @@ -1,4 +1,5 @@ import asyncio +import importlib_metadata import json import logging import sys @@ -161,6 +162,9 @@ async def plugin_toggle(name: str) -> WerkzeugResponse: if enable_plugin: response.set_cookie(f"{WARNING_COOKIE_PREFIX}-{name}", "requires launch", max_age=ONE_MONTH) else: + entrypoints = importlib_metadata.entry_points(name=name) + for entrypoint in entrypoints: + sys.modules.pop(entrypoint.value) response.delete_cookie(f"{WARNING_COOKIE_PREFIX}-{name}") return response