iptables_raw.py 文件源码

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

项目:dcos-ansible-packet 作者: ContainerSolutions 项目源码 文件源码
def acquire_lock_or_exit(self, wait_for_seconds=10):
        lock_file = self.STATE_DIR + '/.iptables.lock'
        i = 0
        f = open(lock_file, 'w+')
        while i < wait_for_seconds:
            try:
                fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
                return
            except IOError:
                i += 1
                time.sleep(1)
        Iptables.module.fail_json(msg="Could not acquire lock to continue execution! "
                                      "Probably another instance of this module is running.")

    # Check if a table has anything to flush (to check all tables pass table='*').
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号