[Catalog-sig] Mirror selection
"Martin v. Löwis"
martin at v.loewis.de
Tue Mar 13 21:17:32 CET 2012
We were just talking about PyPI mirror selection at the sprint,
so people asked me to release the current implementation of my
mirror selection algorithm, which is now at
http://www.dcl.hpi.uni-potsdam.de/home/loewis/_mirrorlib.py
The main function is
def find_mirror(start_with='a',
good_age = 30*60,
slow_mirrors_wait = 5,
prefer_fastest = True):
'''find_mirrors(start_with, good_age, slow_mirrors_wait,
prefer_fastest)
-> [(name, family, IP, response_time, last_modified)]
Find a PyPI mirror matching given criteria.
start_with indicates the first mirror that should be considered
(defaults to 'a').
If prefer_fastest is True, it stops with the first mirror
responding. Mirrors 'compete'
against each other in randomly-shuffled batches of 10.
If this procedure goes on for longer than slow_mirrors_wait
(default 5s) and prefer_fastest
is false, return even if not all mirrors have been responding.
If no matching mirror can be found, the newest one that did
response is returned.
If no mirror can be found at all, ValueError is raised'''
Regards,
Martin
More information about the Catalog-SIG
mailing list