From 7d00427d74450a6ebf3e6bfd0a258392a0f65121 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 10 Jan 2013 01:05:40 -0800 Subject: [PATCH] FetchTask: randomize thirdpartymirrors --- pym/portage/_emirrordist/FetchTask.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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): -- 2.26.2