policy(minor): fix linting

This commit is contained in:
Langhammer, Jens 2019-10-04 13:49:27 +02:00
parent 4c6f562805
commit 1cd149c815
1 changed files with 4 additions and 3 deletions

View File

@ -1,15 +1,15 @@
"""passbook policy engine""" """passbook policy engine"""
from multiprocessing import Pipe from multiprocessing import Pipe
from multiprocessing.connection import Connection from multiprocessing.connection import Connection
from typing import List, Tuple, Dict from typing import List, Tuple
from django.core.cache import cache from django.core.cache import cache
from django.http import HttpRequest from django.http import HttpRequest
from structlog import get_logger from structlog import get_logger
from passbook.core.models import Policy, User from passbook.core.models import Policy, User
from passbook.policy.struct import PolicyRequest, PolicyResult
from passbook.policy.process import PolicyProcess from passbook.policy.process import PolicyProcess
from passbook.policy.struct import PolicyRequest, PolicyResult
LOGGER = get_logger() LOGGER = get_logger()
@ -17,6 +17,7 @@ def _cache_key(policy, user):
return f"policy_{policy.pk}#{user.pk}" return f"policy_{policy.pk}#{user.pk}"
class PolicyProcessInfo: class PolicyProcessInfo:
"""Dataclass to hold all information and communication channels to a process"""
process: PolicyProcess process: PolicyProcess
connection: Connection connection: Connection
@ -79,7 +80,7 @@ class PolicyEngine:
LOGGER.debug("Starting Process", for_policy=policy) LOGGER.debug("Starting Process", for_policy=policy)
task.start() task.start()
self.__processes.append(PolicyProcessInfo(process=task, self.__processes.append(PolicyProcessInfo(process=task,
connection=our_end, policy=policy)) connection=our_end, policy=policy))
# If all policies are cached, we have an empty list here. # If all policies are cached, we have an empty list here.
for proc_info in self.__processes: for proc_info in self.__processes:
proc_info.process.join(proc_info.policy.timeout) proc_info.process.join(proc_info.policy.timeout)