What if we used the cache in the "run_action_on_units" function to prevent the same
action from running again with the same parameters on the same unit.
How should it work:
def run_action_on_units(
units: List[Unit],
action: str,
use_cache: bool = True,
**params: Any
) -> Dict[str, Action]:
"""Run juju action on specified units.
....
"""
if use_cache:
cache_result = {unit.entity_id: CACHE[unit.entity_id] for unit
in units if unit.entity_id in CACHE}
task_map = {unit.entity_id: unit.run_action(action, **params) for unit
in units if unit.entity_id not in cache_result}
What if we used the cache in the "run_action_on_units" function to prevent the same action from running again with the same parameters on the same unit.
How should it work:
def run_action_on_units( units: List[Unit], action: str, use_cache: bool = True, **params: Any ) -> Dict[str, Action]: """Run juju action on specified units. .... """ if use_cache: cache_result = {unit.entity_id: CACHE[unit.entity_id] for unit in units if unit.entity_id in CACHE}
task_map = {unit.entity_id: unit.run_action(action, **params) for unit
in units if unit.entity_id not in cache_result}
Imported from Launchpad using lp2gh.
date created: 2021-03-31T13:17:36Z
owner: rgildein
assignee: rgildein
the launchpad url