[Yum-devel] [PATCH] smart evaluation of repo.async option

Zdeněk Pavlas zpavlas at redhat.com
Fri Apr 20 10:57:27 UTC 2012


False => don't use parallel downloader.
True => use it "if possible".

This is meant to automatically disable parallel
downloading for repositories created by plugins,
which would likely break.

YumRepository instances must set 'self._async'
explicitly to support parallel downloading.
---
 docs/yum.conf.5 |    4 ++--
 yum/__init__.py |    5 +++--
 yum/repos.py    |    4 ++--
 yum/yumRepo.py  |    1 +
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index a44a5b2..e371f7c 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -914,8 +914,8 @@ for any given command. Defaults to False.
 
 .IP
 \fBasync \fR
-If set (the default) and urlgrabber supports it, yum will use parallel downloader
-for packages from this repo.
+If set to True Yum will download packages and metadata from this repo in
+parallel, if possible.  Defaults to True.
 
 .SH "URL INCLUDE SYNTAX"
 .LP
diff --git a/yum/__init__.py b/yum/__init__.py
index 72e2273..c52abd6 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -581,7 +581,8 @@ class YumBase(depsolve.Depsolve):
         repo.basecachedir = self.conf.cachedir
         repo.yumvar.update(self.conf.yumvar)
         repo.cfg = parser
-
+        # Enable parallel downloading
+        repo._async = repo.async
         return repo
 
     def disablePlugins(self):
@@ -2260,7 +2261,7 @@ class YumBase(depsolve.Depsolve):
 
             text = os.path.basename(po.relativepath)
             kwargs = {}
-            if async and po.repo.async:
+            if async and po.repo._async:
                 kwargs['failfunc'] = lambda obj, po=po: adderror(po, exception2msg(obj.exception))
                 kwargs['async'] = True
             elif not (i == 1 and not local_size[0] and remote_size == po.size):
diff --git a/yum/repos.py b/yum/repos.py
index 9ebf895..bd8f1a4 100644
--- a/yum/repos.py
+++ b/yum/repos.py
@@ -78,7 +78,7 @@ class RepoStorage:
 
         repos = []
         for repo in self.listEnabled():
-            if repo.async and repo._commonLoadRepoXML(repo):
+            if repo._async and repo._commonLoadRepoXML(repo):
                 mdtypes = repo._mdpolicy2mdtypes()
                 downloading = repo._commonRetrieveDataMD_list(mdtypes)
                 repos.append((repo, downloading, [False]))
@@ -325,7 +325,7 @@ class RepoStorage:
         if hasattr(urlgrabber.grabber, 'parallel_wait'):
             # download all metadata in parallel
             for repo in myrepos:
-                if repo.async:
+                if repo._async:
                     sack = repo.getPackageSack()
                     sack._retrieve_async(repo, data)
             urlgrabber.grabber.parallel_wait()
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 124ad59..76e05d2 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -307,6 +307,7 @@ class YumRepository(Repository, config.RepoConf):
 
         self._grabfunc = None
         self._grab = None
+        self._async = False
 
     def __cmp__(self, other):
         """ Sort yum repos. by cost, and then by alphanumeric on their id. """
-- 
1.7.4.4



More information about the Yum-devel mailing list