From 65c9d4bf4cea45d121745455a65810100ea78368 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 17 Jan 2021 19:59:19 +0100 Subject: [PATCH] policies: use custom context for fork instead of changing global context --- authentik/policies/process.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/authentik/policies/process.py b/authentik/policies/process.py index 225fb2b6f..da6a58be3 100644 --- a/authentik/policies/process.py +++ b/authentik/policies/process.py @@ -1,5 +1,5 @@ """authentik policy task""" -from multiprocessing import Process +from multiprocessing import get_context from multiprocessing.connection import Connection from traceback import format_tb from typing import Optional @@ -28,7 +28,11 @@ def cache_key(binding: PolicyBinding, request: PolicyRequest) -> str: return prefix -class PolicyProcess(Process): +FORK_CTX = get_context("fork") +PROCESS_CLASS = FORK_CTX.Process + + +class PolicyProcess(PROCESS_CLASS): """Evaluate a single policy within a seprate process""" connection: Connection