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,
)
评论列表
文章目录