[Yum-devel] [PATCH] repo.async = 'auto' option

Zdeněk Pavlas zpavlas at redhat.com
Tue Apr 17 08:04:31 UTC 2012


Make 'async' option 3-state.  'auto' evaluates to '1'
only in base Yum repository parsed from INI file.

When plugins create subclasses they may inherit options
from Yum repository so we should not just modify them.
Used a private _async attribute instead.
---
 docs/yum.conf.5 |    4 ++--
 yum/__init__.py |    6 +++++-
 yum/config.py   |    6 ++++--
 yum/repos.py    |    4 ++--
 yum/yumRepo.py  |    1 +
 5 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index a44a5b2..220d88e 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 and urlgrabber supports it, yum will use parallel downloader for packages
+and metadata from this repo.  Defaults to 'auto' (on for yum repositories only).
 
 .SH "URL INCLUDE SYNTAX"
 .LP
diff --git a/yum/__init__.py b/yum/__init__.py
index 72e2273..1263044 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -582,6 +582,10 @@ class YumBase(depsolve.Depsolve):
         repo.yumvar.update(self.conf.yumvar)
         repo.cfg = parser
 
+        # Good old YumRepository handles that
+        if repo.async == 'auto':
+            repo._async = True
+
         return repo
 
     def disablePlugins(self):
@@ -2260,7 +2264,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/config.py b/yum/config.py
index 591603c..ba6f095 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -957,8 +957,10 @@ class RepoConf(BaseConfig):
     ssl_check_cert_permissions = Inherit(YumConf.ssl_check_cert_permissions)
 
     skip_if_unavailable = BoolOption(False)
-    async = BoolOption(True)
-    
+    async = SelectionOption('auto', ('auto', '0', '1'),
+                            mapper={'off': '0', 'false': '0',
+                                    'on': '1', 'true': '1'})
+
 class VersionGroupConf(BaseConfig):
     """Option definitions for version groups."""
 
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 2aa3c88..c4f8dd0 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 = self.async == '1' # disabled if 'auto'
 
     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