From e20c2542cb748187804802178d3051cb2aec58d0 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Tue, 23 Jun 2020 14:51:58 +0100 Subject: [PATCH] target/manager: Allow specifying usage of target_info cache Allow disabling of the usage of the target_info cache. This is useful when running on a one-off target and there is no benefit of using caching the target information. --- wa/framework/target/manager.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/wa/framework/target/manager.py b/wa/framework/target/manager.py index 315f6a181..0a84e6a92 100644 --- a/wa/framework/target/manager.py +++ b/wa/framework/target/manager.py @@ -37,6 +37,11 @@ class TargetManager(object): Specifies whether the target should be disconnected from at the end of the run. """), + Parameter('cache_target_info', kind=bool, default=True, + description=""" + Configure whether the cache should be used when collecting + target information. + """), ] def __init__(self, name, parameters, outdir): @@ -50,6 +55,7 @@ def __init__(self, name, parameters, outdir): self.rpm = None self.parameters = parameters self.disconnect = parameters.get('disconnect') + self.cache_target_info = parameters.get('cache_target_info') def initialize(self): self._init_target() @@ -89,18 +95,21 @@ def extract_results(self, context): @memoized def get_target_info(self): - info = get_target_info_from_cache(self.target.system_id) + if self.cache_target_info: + info = get_target_info_from_cache(self.target.system_id) - if info is None: - info = get_target_info(self.target) - cache_target_info(info) - else: - # If module configuration has changed form when the target info - # was previously cached, it is possible additional info will be - # available, so should re-generate the cache. - if module_name_set(info.modules) != module_name_set(self.target.modules): + if info is None: info = get_target_info(self.target) - cache_target_info(info, overwrite=True) + cache_target_info(info) + else: + # If module configuration has changed form when the target info + # was previously cached, it is possible additional info will be + # available, so should re-generate the cache. + if module_name_set(info.modules) != module_name_set(self.target.modules): + info = get_target_info(self.target) + cache_target_info(info, overwrite=True) + else: + info = get_target_info(self.target) return info