summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-01-10 01:05:40 -0800
committerZac Medico <zmedico@gentoo.org>2013-01-10 01:05:40 -0800
commit7d00427d74450a6ebf3e6bfd0a258392a0f65121 (patch)
treeaed5901d6036f04a4f6ace8b335668641fab66e0
parentebb6a97eb926c030eb933e84041b7673335cab41 (diff)
downloadportage-7d00427d74450a6ebf3e6bfd0a258392a0f65121.tar.gz
portage-7d00427d74450a6ebf3e6bfd0a258392a0f65121.tar.bz2
portage-7d00427d74450a6ebf3e6bfd0a258392a0f65121.zip
FetchTask: randomize thirdpartymirrors
-rw-r--r--pym/portage/_emirrordist/FetchTask.py8
1 files changed, 7 insertions, 1 deletions
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):