From 4eff50917ab0dd3c965422c644df5f8f3e5fe7f7 Mon Sep 17 00:00:00 2001 From: aranega Date: Sat, 12 Oct 2024 13:11:48 -0600 Subject: [PATCH] Remove caching for config Otherwise, this introduces issues of coroutine that are reused --- applications/visualizer/backend/api/utils.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/applications/visualizer/backend/api/utils.py b/applications/visualizer/backend/api/utils.py index 63eda17..a1299a3 100644 --- a/applications/visualizer/backend/api/utils.py +++ b/applications/visualizer/backend/api/utils.py @@ -1,6 +1,3 @@ -import time -from functools import lru_cache, partial, update_wrapper -from django.utils.functional import lazy from django.conf import settings from .schemas import EMData @@ -12,21 +9,6 @@ async def to_list(q): return [x async for x in q] -def lru_cache_time(seconds, maxsize=None): - def wrapper(func): - # Lazy function that makes sure the lru_cache() invalidate after X secs - ttl_hash = lazy(lambda: round(time.time() / seconds), int)() - - @lru_cache(maxsize) - def time_aware(__ttl, *args, **kwargs): - return func(*args, **kwargs) - - return update_wrapper(partial(time_aware, ttl_hash), func) - - return wrapper - - -@lru_cache_time(seconds=60 * 60, maxsize=10) # We cache information for 1h async def get_dataset_viewer_config(dataset: Dataset): config = await dataset.config.afirst() # type: ignore if config is None: