[Yum-devel] [PATCH 1/3] add 'max_connections' option
Ales Kozumplik
akozumpl at redhat.com
Thu Dec 22 08:25:33 UTC 2011
On 12/21/2011 05:01 PM, Zdeněk Pavlas wrote:
> This option sets the connection limit of the baseurl host.
> Mirrors use connection limits from metalink.xml.
> Also, the value of this option is sent to the MG instance
> and controls how many mirrors are used initially.
> ---
> docs/yum.conf.5 | 15 ++++++++++++---
> yum/config.py | 2 ++
> yum/metalink.py | 8 ++++----
> yum/yumRepo.py | 19 ++++++++++++++++---
> 4 files changed, 34 insertions(+), 10 deletions(-)
Ack from me, with some notes:
> --- a/yum/yumRepo.py
> +++ b/yum/yumRepo.py
> @@ -490,9 +490,22 @@ class YumRepository(Repository, config.RepoConf):
> copy_local=self.copy_local,
> reget='simple',
> **ugopts)
> -
> - self._grab = mgclass(self._grabfunc, self.urls,
> - failure_callback=self.mirror_failure_obj)
> + def add_limit(url):
I have never seen it mentioned in PEP008 but it is a good form to put
the inner function definitions at the beginning of the enclosing
function, to ease reading later.
> + limit = None
> + if url in self._orig_baseurl:
> + limit = self.max_connections
> + elif self.metalink:
> + host = urlparse.urlsplit(url).netloc
> + limit = self.metalink_data.host2con.get(host)
> + if limit: url = {
> + 'mirror': misc.to_utf8(url),
> + 'kwargs': { 'max_connections': limit },
> + }
> + return url
> + urls = map(add_limit, self.urls)
> + self._grab = mgclass(self._grabfunc, urls,
> + failure_callback=self.mirror_failure_obj,
> + max_connections=self.max_connections)
Not sure if something can be done about it but urls is now a mixed list
of strings and dictionaries, something that might look surprising later
(it is probably a flaw on urlgrabber side to be willing to accept both
instead of enforcing dicts/objects).
Ales
More information about the Yum-devel
mailing list