On Fri, 2011-10-21 at 16:30 +0200, Zdeněk Pavlas wrote: > Use the max_connection attribute from metalink parser > when building MirrorGroup arguments, so it's available > to the parallel download scheduller. > --- > yum/metalink.py | 2 +- > yum/yumRepo.py | 12 +++++++++--- > 2 files changed, 10 insertions(+), 4 deletions(-) > > diff --git a/yum/metalink.py b/yum/metalink.py > index aaa4f25..90b0053 100755 > --- a/yum/metalink.py > +++ b/yum/metalink.py > @@ -248,7 +248,7 @@ class MetaLinkRepoMD: > # of mirror baseurls. Joy of reusing other people's stds. :) > if not url.endswith("/repodata/repomd.xml"): > continue > - yield url[:-len("/repodata/repomd.xml")] > + yield url[:-len("/repodata/repomd.xml")], mirror.max_connections
We can't change the API of metalink.urls like this. This is one of the reasons we still aren't using the private mirror attribute. Probably need some new API to return "url objects" which will have private/max_connections/etc. attributes. > def __str__(self): > ret = str(self.repomd) > diff --git a/yum/yumRepo.py b/yum/yumRepo.py > index 91b7dde..1181fae 100644 > --- a/yum/yumRepo.py > +++ b/yum/yumRepo.py > @@ -287,6 +287,7 @@ class YumRepository(Repository, config.RepoConf): > > self._grabfunc = None > self._grab = None > + self._max_connections = {} > > def __cmp__(self, other): > """ Sort yum repos. by cost, and then by alphanumeric on their id. > """ > @@ -491,7 +492,11 @@ class YumRepository(Repository, config.RepoConf): > reget='simple', > **ugopts) > > - self._grab = mgclass(self._grabfunc, self.urls, > + def max_con(url): > + con = self._max_connections.get(url) > + if con: url = { 'mirror': misc.to_utf8(url), 'max_connections': > con } > + return url > + self._grab = mgclass(self._grabfunc, map(max_con, self.urls), > failure_callback=self.mirror_failure_obj) The MirroGroup magic is documented as: 2) Custom mirror list - Mirror lists can simply be a list of stings mirrors (as shown in the example above) but each can also be a dict, allowing for more options. For example, the first mirror in the list above could also have been: {'mirror': 'http://foo.com/some/directory/', 'grabber': <a custom grabber to be used for this mirror>, 'kwargs': { <a dict of arguments passed to the grabber> }} All mirrors are converted to this format internally. ...so if we are going to add random attributes to the dict we should document that ... or just use the kwargs indirection, and document that. _______________________________________________ Yum-devel mailing list Yum-devel@lists.baseurl.org http://lists.baseurl.org/mailman/listinfo/yum-devel