[Yum-devel] [PATCH 4/4] populateSack(): parallel metadata downloading

Zdeněk Pavlas zpavlas at redhat.com
Wed Mar 28 15:06:40 UTC 2012


---
 yum/repos.py   |    8 ++++++++
 yum/yumRepo.py |   19 +++++++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/yum/repos.py b/yum/repos.py
index 9679974..bc55a19 100644
--- a/yum/repos.py
+++ b/yum/repos.py
@@ -314,6 +314,14 @@ class RepoStorage:
         else:
             data = [ mdtype ]
          
+        if hasattr(urlgrabber.grabber, 'parallel_wait'):
+            # download all metadata in parallel
+            for repo in myrepos:
+                if repo.async:
+                    sack = repo.getPackageSack()
+                    sack.pre_populate(repo, data)
+            urlgrabber.grabber.parallel_wait()
+
         for repo in myrepos:
             sack = repo.getPackageSack()
             try:
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 9441cf6..4596307 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -124,6 +124,25 @@ class YumPackageSack(packageSack.PackageSack):
             # umm, wtf?
             pass
 
+    def pre_populate(self, repo, data):
+        """ Just schedule the metadata downloads """
+
+        for item in data:
+            if item in self.added.get(repo, []):
+                continue
+            if item == 'metadata':
+                mydbtype = 'primary_db'
+            elif item == 'filelists':
+                mydbtype = 'filelists_db'
+            elif item == 'otherdata':
+                mydbtype = 'other_db'
+            else:
+                continue
+
+            if self._check_db_version(repo, mydbtype):
+                if not self._check_uncompressed_db(repo, mydbtype):
+                    repo._retrieveMD(mydbtype, async=True, failfunc=None)
+
     def populate(self, repo, mdtype='metadata', callback=None, cacheonly=0):
         if mdtype == 'all':
             data = ['metadata', 'filelists', 'otherdata']
-- 
1.7.4.4



More information about the Yum-devel mailing list