Merge pull request #5354 from FinnStutzenstein/fixUnnenessaryBrokenLock

Fix unnecessary and unfunctional lock for production usage with gunicorn
This commit is contained in:
Emanuel Schütze 2020-05-06 17:29:28 +02:00 committed by GitHub
commit 5aa895bda2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,3 @@
import asyncio
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast
from asgiref.sync import async_to_sync from asgiref.sync import async_to_sync
@ -28,8 +27,6 @@ INPUT_TYPE_MAPPING = {
ALLOWED_NONE = ("datetimepicker",) ALLOWED_NONE = ("datetimepicker",)
build_key_to_id_lock = asyncio.Lock()
class ConfigHandler: class ConfigHandler:
""" """
@ -77,15 +74,8 @@ class ConfigHandler:
async def build_key_to_id(self) -> None: async def build_key_to_id(self) -> None:
""" """
Build the key_to_id dict. Build the key_to_id dict, if it does not exists.
Recreates it, if it does not exists.
This uses the element_cache. It expects, that the config values are in the database
before this is called.
""" """
async with build_key_to_id_lock:
# Another worker could have build the key_to_id_dict, check and return early
if self.key_to_id is not None: if self.key_to_id is not None:
return return