mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 04:40:22 -07:00
Adding aliases for field attributes and renaming async attribute (#33141)
* Adding aliases for field attributes and renaming async attribute As of Python 3.7, the use of async raises an error, whereas before the use of the reserved word was ignored. This adds an alias field for field attrs so that both async and async_val (interally) work. This allows us to be backwards-compatible with 3rd party plugins that may still reference Task.async, but for the core engine to work on Py3.7+. * Remove files fixed for 'async' usage from the python 3.7 skip list
This commit is contained in:
parent
23f8833e87
commit
d8ae4dfbf2
14 changed files with 43 additions and 36 deletions
|
@ -93,11 +93,11 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
|
||||
result = {}
|
||||
|
||||
if self._task.async and not self._supports_async:
|
||||
if self._task.async_val and not self._supports_async:
|
||||
raise AnsibleActionFail('async is not supported for this task.')
|
||||
elif self._play_context.check_mode and not self._supports_check_mode:
|
||||
raise AnsibleActionSkip('check mode is not supported for this task.')
|
||||
elif self._task.async and self._play_context.check_mode:
|
||||
elif self._task.async_val and self._play_context.check_mode:
|
||||
raise AnsibleActionFail('check mode and async cannot be used on same task.')
|
||||
|
||||
return result
|
||||
|
@ -159,7 +159,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
|
||||
(module_data, module_style, module_shebang) = modify_module(module_name, module_path, module_args,
|
||||
task_vars=task_vars, module_compression=self._play_context.module_compression,
|
||||
async_timeout=self._task.async, become=self._play_context.become,
|
||||
async_timeout=self._task.async_val, become=self._play_context.become,
|
||||
become_method=self._play_context.become_method, become_user=self._play_context.become_user,
|
||||
become_password=self._play_context.become_pass,
|
||||
environment=final_environment)
|
||||
|
@ -703,7 +703,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
self._transfer_data(remote_async_module_path, async_module_data)
|
||||
remote_files.append(remote_async_module_path)
|
||||
|
||||
async_limit = self._task.async
|
||||
async_limit = self._task.async_val
|
||||
async_jid = str(random.randint(0, 999999999999))
|
||||
|
||||
# call the interpreter for async_wrapper directly
|
||||
|
|
|
@ -114,7 +114,7 @@ class ActionModule(ActionBase):
|
|||
display.vvvv('Running implementation module %s' % module)
|
||||
result.update(self._execute_module(module_name=module,
|
||||
module_args=new_module_args, task_vars=task_vars,
|
||||
wrap_async=self._task.async))
|
||||
wrap_async=self._task.async_val))
|
||||
|
||||
display.vvvv('Caching network OS %s in facts' % play_context.network_os)
|
||||
result['ansible_facts'] = {'network_os': play_context.network_os}
|
||||
|
|
|
@ -39,7 +39,7 @@ class ActionModule(ActionBase):
|
|||
del results['invocation']['module_args']
|
||||
|
||||
# FUTURE: better to let _execute_module calculate this internally?
|
||||
wrap_async = self._task.async and not self._connection.has_native_async
|
||||
wrap_async = self._task.async_val and not self._connection.has_native_async
|
||||
|
||||
# do work!
|
||||
results = merge_hash(results, self._execute_module(tmp=tmp, task_vars=task_vars, wrap_async=wrap_async))
|
||||
|
|
|
@ -66,7 +66,7 @@ class ActionModule(ActionBase):
|
|||
del new_module_args['use']
|
||||
|
||||
display.vvvv("Running %s" % module)
|
||||
result.update(self._execute_module(module_name=module, module_args=new_module_args, task_vars=task_vars, wrap_async=self._task.async))
|
||||
result.update(self._execute_module(module_name=module, module_args=new_module_args, task_vars=task_vars, wrap_async=self._task.async_val))
|
||||
else:
|
||||
result['failed'] = True
|
||||
result['msg'] = 'Could not detect which package manager to use. Try gathering facts or setting the "use" option.'
|
||||
|
|
|
@ -74,7 +74,7 @@ class ActionModule(ActionBase):
|
|||
self._display.warning('Ignoring "%s" as it is not used in "%s"' % (unused, module))
|
||||
|
||||
self._display.vvvv("Running %s" % module)
|
||||
result.update(self._execute_module(module_name=module, module_args=new_module_args, task_vars=task_vars, wrap_async=self._task.async))
|
||||
result.update(self._execute_module(module_name=module, module_args=new_module_args, task_vars=task_vars, wrap_async=self._task.async_val))
|
||||
else:
|
||||
result['failed'] = True
|
||||
result['msg'] = 'Could not detect which service manager to use. Try gathering facts or setting the "use" option.'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue