policies: use custom context for fork instead of changing global context

This commit is contained in:
Jens Langhammer 2021-01-17 19:59:19 +01:00
parent 222cece3e1
commit b86d4a455d
1 changed files with 6 additions and 2 deletions

View File

@ -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