_ansible.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:0ops.exed 作者: whisperaven 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号