mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
Parse async response in async action. (#16534)
* Parse async response in async action. * Add async test for non-JSON data before module output. * Fix existing async unit test. Resolves #16156
This commit is contained in:
parent
f86c527736
commit
292785ff2b
5 changed files with 29 additions and 12 deletions
|
@ -458,15 +458,6 @@ class TaskExecutor:
|
|||
vars_copy[self._task.register] = wrap_var(result.copy())
|
||||
|
||||
if self._task.async > 0:
|
||||
# the async_wrapper module returns dumped JSON via its stdout
|
||||
# response, so we parse it here and replace the result
|
||||
try:
|
||||
if 'skipped' in result and result['skipped'] or 'failed' in result and result['failed']:
|
||||
return result
|
||||
result = json.loads(result.get('stdout'))
|
||||
except (TypeError, ValueError) as e:
|
||||
return dict(failed=True, msg=u"The async task did not return valid JSON: %s" % to_unicode(e))
|
||||
|
||||
if self._task.poll > 0:
|
||||
result = self._poll_async_result(result=result, templar=templar)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue