[Python-checkins] r42156 - sandbox/trunk/setuptools/setuptools/package_index.py
phillip.eby
python-checkins at python.org
Mon Jan 23 17:29:16 CET 2006
Author: phillip.eby
Date: Mon Jan 23 17:29:16 2006
New Revision: 42156
Modified:
sandbox/trunk/setuptools/setuptools/package_index.py
Log:
Randomly select a SourceForge mirror IP for each download, to work
around too-aggressive DNS caches on some platforms, that could otherwise
result in a stuck bad IP.
Modified: sandbox/trunk/setuptools/setuptools/package_index.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/package_index.py (original)
+++ sandbox/trunk/setuptools/setuptools/package_index.py Mon Jan 23 17:29:16 2006
@@ -1,6 +1,6 @@
"""PyPI and direct package downloading"""
-import sys, os.path, re, urlparse, urllib2, shutil
+import sys, os.path, re, urlparse, urllib2, shutil, random, socket
from pkg_resources import *
from distutils import log
from distutils.errors import DistutilsError
@@ -562,18 +562,28 @@
log.warn(msg, *args)
+
+
+
+
+
+
+
+
+
+
def fix_sf_url(url):
scheme, server, path, param, query, frag = urlparse.urlparse(url)
if server!='prdownloads.sourceforge.net':
return url
return urlparse.urlunparse(
- (scheme, 'dl.sourceforge.net', 'sourceforge'+path, param, '', frag)
+ (scheme, get_sf_ip(), 'sourceforge'+path, param, '', frag)
)
-
-
-
-
+def get_sf_ip(_mirrors=[]):
+ if not _mirrors:
+ _mirrors[:] = socket.gethostbyname_ex('dl.sourceforge.net')[-1]
+ return random.choice(_mirrors)
More information about the Python-checkins
mailing list