runner.py 文件源码

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

项目:bay 作者: eventbrite 项目源码 文件源码
def stop_containers(self, instances):
        """
        Stops all the specified containers in parallel, still respecting links
        """
        current_formation = self.introspector.introspect()

        # Inner function that we can pass to dependency_sort
        @functools.lru_cache(maxsize=512)
        def get_incoming_links(instance):
            result = set()
            for potential_linker in current_formation:
                links_to = potential_linker.links.values()
                if instance in links_to:
                    result.add(potential_linker)
            return result

        # Resolve container list to include descendency
        instances = dependency_sort(instances, get_incoming_links)
        # Parallel-stop things
        self.parallel_execute(
            instances,
            lambda instance, done: all((linker in done) for linker in get_incoming_links(instance)),
            executor=self.stop_container,
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号