[yum-commits] yum/yumRepo.py

zpavlas at osuosl.org zpavlas at osuosl.org
Tue Apr 16 12:58:40 UTC 2013


 yum/yumRepo.py |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

New commits:
commit bfb49e7deab1394ff2c799ce345f69bf0a9583bd
Author: Zdenek Pavlas <zpavlas at redhat.com>
Date:   Fri Apr 12 12:43:50 2013 +0200

    Reuse mirrors when max_retries > len(mirrors).  BZ 765598
    
    When there's less mirrors than the retry limit, we should
    reuse mirrors.  A wrapper around the mirror failure callback
    implements this.

diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index b9bf1fe..2e4fcd9 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -628,8 +628,26 @@ class YumRepository(Repository, config.RepoConf):
         if self.metalink:
             urls = map(add_mc, urls)
 
+        def mirror_failure(obj):
+            action = {}
+
+            # special handling of 503 errors
+            if getattr(obj.exception, 'code', 0) == 503:
+                tries = getattr(obj, 'tries', self.retries)
+                if tries <= self.retries - len(self.urls):
+                    # don't remove this mirror yet
+                    action['remove'] = False
+
+            # No known user of this callback, but just in case...
+            cb = self.mirror_failure_obj
+            if cb:
+                fun, arg, karg = callable(cb) and (cb, (), {}) or cb
+                action.update(fun(obj, *arg, **karg))
+
+            return action
+
         self._grab = mgclass(self._grabfunc, urls,
-                             failure_callback=self.mirror_failure_obj)
+                             failure_callback=mirror_failure)
 
     def _default_grabopts(self, cache=True):
         opts = { 'keepalive': self.keepalive,


More information about the Yum-commits mailing list