From 26b35c9b7b276ec95d333db6b6c1533c977f0791 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 8 Dec 2021 21:42:48 +0100 Subject: [PATCH] root: fix name conflict in threadlocal Signed-off-by: Jens Langhammer --- authentik/root/celery.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/authentik/root/celery.py b/authentik/root/celery.py index 9257d3f20..4698253b6 100644 --- a/authentik/root/celery.py +++ b/authentik/root/celery.py @@ -46,7 +46,7 @@ def after_task_publish_hook(sender=None, headers=None, body=None, **kwargs): def task_prerun_hook(task_id, task, *args, **kwargs): """Log task_id on worker""" request_id = "task-" + uuid4().hex[5:] - LOCAL.authentik = { + LOCAL.authentik_task = { "request_id": request_id, } LOGGER.debug("Task started", task_id=task_id, task_name=task.__name__) @@ -57,8 +57,10 @@ def task_prerun_hook(task_id, task, *args, **kwargs): def task_postrun_hook(task_id, task, *args, retval=None, state=None, **kwargs): """Log task_id on worker""" LOGGER.debug("Task finished", task_id=task_id, task_name=task.__name__, state=state) - for key in list(LOCAL.authentik.keys()): - del LOCAL.authentik[key] + if not hasattr(LOCAL, "authentik_task"): + return + for key in list(LOCAL.authentik_task.keys()): + del LOCAL.authentik_task[key] # pylint: disable=unused-argument