瀏覽代碼

Hide parallel pull behind --parallel flag

Signed-off-by: Evan Shaw <[email protected]>
Evan Shaw 8 年之前
父節點
當前提交
c6a271e57c
共有 2 個文件被更改,包括 18 次插入11 次删除
  1. 3 1
      compose/cli/main.py
  2. 15 10
      compose/project.py

+ 3 - 1
compose/cli/main.py

@@ -602,10 +602,12 @@ class TopLevelCommand(object):
 
         Options:
             --ignore-pull-failures  Pull what it can and ignores images with pull failures.
+            --parallel              Pull multiple images in parallel.
         """
         self.project.pull(
             service_names=options['SERVICE'],
-            ignore_pull_failures=options.get('--ignore-pull-failures')
+            ignore_pull_failures=options.get('--ignore-pull-failures'),
+            in_parallel=options.get('--parallel')
         )
 
     def push(self, options):

+ 15 - 10
compose/project.py

@@ -454,17 +454,22 @@ class Project(object):
 
         return plans
 
-    def pull(self, service_names=None, ignore_pull_failures=False):
-        def pull_service(service):
-            service.pull(ignore_pull_failures, True)
-
+    def pull(self, service_names=None, ignore_pull_failures=False, in_parallel=False):
         services = self.get_services(service_names, include_deps=False)
-        parallel.parallel_execute(
-            services,
-            pull_service,
-            operator.attrgetter('name'),
-            'Pulling',
-            limit=5)
+
+        if in_parallel:
+            def pull_service(service):
+                service.pull(ignore_pull_failures, True)
+
+            parallel.parallel_execute(
+                services,
+                pull_service,
+                operator.attrgetter('name'),
+                'Pulling',
+                limit=5)
+        else:
+            for service in services:
+                service.pull(ignore_pull_failures)
 
     def push(self, service_names=None, ignore_push_failures=False):
         for service in self.get_services(service_names, include_deps=False):