From 2f57d390aaf1d5cf4bf59de3f129f0aeb78cd813 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Tue, 18 Jun 2024 03:03:16 +0800 Subject: [PATCH] Add: [ALAS] set_cached_property --- module/base/decorator.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/module/base/decorator.py b/module/base/decorator.py index f4d693735..e507282aa 100644 --- a/module/base/decorator.py +++ b/module/base/decorator.py @@ -123,6 +123,18 @@ def has_cached_property(obj, name): return name in obj.__dict__ +def set_cached_property(obj, name, value): + """ + Set a cached property. + + Args: + obj: + name (str): + value: + """ + obj.__dict__[name] = value + + def function_drop(rate=0.5, default=None): """ Drop function calls to simulate random emulator stuck, for testing purpose.