From 8b5870a9f3671b25def0a2081fcea09467e5cdbf Mon Sep 17 00:00:00 2001 From: David Hammer <dhammer@mailbox.org> Date: Tue, 2 Nov 2021 10:31:53 +0100 Subject: [PATCH] No functools.cached_property in Python 3.6 --- src/calng/calcat_utils.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/calng/calcat_utils.py b/src/calng/calcat_utils.py index ce9d9811..3f5753fb 100644 --- a/src/calng/calcat_utils.py +++ b/src/calng/calcat_utils.py @@ -308,7 +308,9 @@ class BaseCalcatFriend: """Helper to update information about found constants on device""" self.device.set(f"{self.status_prefix}.{constant.name}.{key}", value) - @functools.cached_property + # Python 3.6 does not have functools.cached_property or even functools.cache + @property + @functools.lru_cache() def detector_id(self): detector_name = self._get_param("detectorName") resp = Detector.get_by_identifier(self.client, detector_name) @@ -317,7 +319,8 @@ class BaseCalcatFriend: self._set_param("detectorId", str(res)) return res - @functools.cached_property + @property + @functools.lru_cache() def detector_type_id(self): detector_type = self._get_param("detectorType") resp = DetectorType.get_by_name(self.client, detector_type) @@ -328,7 +331,8 @@ class BaseCalcatFriend: self._set_param("detectorTypeId", str(res)) return res - @functools.cached_property + @property + @functools.lru_cache() def pdus(self): resp = PhysicalDetectorUnit.get_all_by_detector( self.client, self.detector_id, self._get_param("deviceMappingSnapshotAt") @@ -339,11 +343,13 @@ class BaseCalcatFriend: del pdu[irrelevant_key] return resp["data"] - @functools.cached_property + @property + @functools.lru_cache() def _karabo_da_to_float_uuid(self): return {pdu["karabo_da"]: pdu["float_uuid"] for pdu in self.pdus} - @functools.cached_property + @property + @functools.lru_cache() def _karabo_da_to_id(self): return {pdu["karabo_da"]: pdu["id"] for pdu in self.pdus} -- GitLab