From: Zac Medico Date: Thu, 10 Jan 2013 09:05:40 +0000 (-0800) Subject: FetchTask: randomize thirdpartymirrors X-Git-Tag: v2.2.0_alpha150~7 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7d00427d74450a6ebf3e6bfd0a258392a0f65121;p=portage.git FetchTask: randomize thirdpartymirrors --- diff --git a/pym/portage/_emirrordist/FetchTask.py b/pym/portage/_emirrordist/FetchTask.py index 61b567bf6..50e424289 100644 --- a/pym/portage/_emirrordist/FetchTask.py +++ b/pym/portage/_emirrordist/FetchTask.py @@ -4,6 +4,7 @@ import collections import errno import logging +import random import stat import subprocess import sys @@ -206,7 +207,12 @@ class FetchTask(CompositeTask): slash_index = uri.find("/", 9) if slash_index != -1: mirror_name = uri[9:slash_index].strip("/") - for mirror in mirrors_dict.get(mirror_name, []): + mirrors = mirrors_dict.get(mirror_name) + if not mirrors: + return + mirrors = list(mirrors) + while mirrors: + mirror = mirrors.pop(random.randint(0, len(mirrors) - 1)) yield mirror.rstrip("/") + "/" + uri[slash_index+1:] def _try_next_mirror(self):