Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/DIRAC/DataManagementSystem/Utilities/DMSHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

from __future__ import annotations

from cachetools import LRUCache, cachedmethod
from cachetools import LRUCache, TTLCache, cached, cachedmethod
from cachetools.keys import hashkey
from collections.abc import Iterable

from collections import defaultdict
from threading import Lock
Expand All @@ -22,6 +23,14 @@
sLog = gLogger.getSubLogger(__name__)


def _resolveSEGroup_key(seGroupList: str, allSEs: Iterable[str] | None = None):
se_group_list_key = [seGroupList] if isinstance(seGroupList, str) else seGroupList
all_se_key = allSEs if allSEs else ()

return hashkey(tuple(sorted(se_group_list_key)), tuple(sorted(all_se_key)))


@cached(LRUCache(maxsize=128), lock=Lock(), key=_resolveSEGroup_key)
def resolveSEGroup(seGroupList, allSEs=None):
"""
Resolves recursively a (list of) SEs that can be groupSEs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,10 @@ def jobIDPath():
@pytest.fixture
def setup_another_job_wrapper(mocker, jobIDPath):
"""Fixture to create a JobWrapper instance with the jobIDPath."""
# Reset the cache otherwise some tests don't pass
from DIRAC.DataManagementSystem.Utilities.DMSHelpers import resolveSEGroup

resolveSEGroup.cache_clear()
jw = JobWrapper(jobIDPath)
jw.jobIDPath = Path(str(jobIDPath))
jw.failedFlag = False
Expand Down
Loading