From 2c06eed8e750f42183d2f654775b4b6b2e9558dc Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 18 Oct 2021 14:48:14 +0200 Subject: [PATCH] events: don't prefill task if they already have a state Signed-off-by: Jens Langhammer --- authentik/events/monitored_tasks.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/authentik/events/monitored_tasks.py b/authentik/events/monitored_tasks.py index d867bba78..707aa0d3c 100644 --- a/authentik/events/monitored_tasks.py +++ b/authentik/events/monitored_tasks.py @@ -81,7 +81,7 @@ class TaskInfo: @staticmethod def by_name(name: str) -> Optional["TaskInfo"]: """Get TaskInfo Object by name""" - return cache.get(f"task_{name}") + return cache.get(f"task_{name}", None) def delete(self): """Delete task info from cache""" @@ -116,6 +116,9 @@ def prefill_task(): """Ensure a task's details are always in cache, so it can always be triggered via API""" def inner_wrap(func): + status = TaskInfo.by_name(func.__name__) + if status: + return func TaskInfo( task_name=func.__name__, task_description=func.__doc__,