Cache task_vars to speed up IncludedFile.process_include_results (#39026)

pull/39117/head
Matt Martz 7 years ago committed by GitHub
parent fd50248463
commit afcc9ddf8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -54,6 +54,7 @@ class IncludedFile:
@staticmethod @staticmethod
def process_include_results(results, iterator, loader, variable_manager): def process_include_results(results, iterator, loader, variable_manager):
included_files = [] included_files = []
task_vars_cache = {}
for res in results: for res in results:
@ -73,7 +74,11 @@ class IncludedFile:
if 'skipped' in include_result and include_result['skipped'] or 'failed' in include_result and include_result['failed']: if 'skipped' in include_result and include_result['skipped'] or 'failed' in include_result and include_result['failed']:
continue continue
task_vars = variable_manager.get_vars(play=iterator._play, host=original_host, task=original_task) cache_key = (iterator._play, original_host, original_task)
try:
task_vars = task_vars_cache[cache_key]
except KeyError:
task_vars = task_vars_cache[cache_key] = variable_manager.get_vars(play=iterator._play, host=original_host, task=original_task)
templar = Templar(loader=loader, variables=task_vars) templar = Templar(loader=loader, variables=task_vars)
include_variables = include_result.get('include_variables', dict()) include_variables = include_result.get('include_variables', dict())

Loading…
Cancel
Save