[Yum-devel] [PATCH 4/6] downloadPkgs: use parallel downloader

Zdeněk Pavlas zpavlas at redhat.com
Fri Jan 27 12:30:06 UTC 2012


---
 yum/__init__.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/yum/__init__.py b/yum/__init__.py
index 3329828..1478df7 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2161,6 +2161,7 @@ class YumBase(depsolve.Depsolve):
         i = 0
         local_size = [0]
         done_repos = set()
+        async = hasattr(urlgrabber.grabber, 'parallel_wait')
         for po in remote_pkgs:
             #  Recheck if the file is there, works around a couple of weird
             # edge cases.
@@ -2194,6 +2195,10 @@ class YumBase(depsolve.Depsolve):
                 if po in errors:
                     del errors[po]
 
+            kwargs = {}
+            if async and po.repo.async:
+                kwargs['failfunc'] = lambda obj, po=po: adderror(po, exception2msg(obj.exception))
+                kwargs['async'] = True
             try:
                 if i == 1 and not local_size[0] and remote_size == po.size:
                     text = os.path.basename(po.relativepath)
@@ -2204,9 +2209,12 @@ class YumBase(depsolve.Depsolve):
                                    checkfunc=checkfunc,
                                    text=text,
                                    cache=po.repo.http_caching != 'none',
+                                   **kwargs
                                    )
             except Errors.RepoError, e:
                 adderror(po, exception2msg(e))
+        if async:
+            urlgrabber.grabber.parallel_wait()
 
         if hasattr(urlgrabber.progress, 'text_meter_total_size'):
             urlgrabber.progress.text_meter_total_size(0)
-- 
1.7.4.4



More information about the Yum-devel mailing list