def _run_tasks(self, play, reaper):
""" Init TQM and run play. """
tqm = TaskQueueManager(inventory=self._inventory,
variable_manager=self._varmanager,
loader=self._loader,
options=self._opts,
passwords=None,
stdout_callback=reaper)
# with multiprocessing, the parent cannot handle exception riased
# by the child process.
# which means, the try/except in the `runner._async_deploy` cannot
# known what happened here, and cause the entire celery worker
# process stop working without exit.
# Solution:
# 1, handle ansible exception here (inside executor).
# 2, cannot raise other exception in `except` block, because of
# this piece of code may be run under other `fork()`.
# 3, because of <2>, we use `reaper` to tell outside something going wrong.
try:
tqm.run(play)
except AnsibleError:
reaper.reaper_exception(ExecutorPrepareError(str(excinst())))
finally:
tqm.cleanup()
reaper.done()
评论列表
文章目录