Commit 89112489 authored by Julien Muchembled's avatar Julien Muchembled

Work around setuptools bug not catching some network timeouts

This fixes random failures when running in newest mode (which is the default
case), or when the requested version is available in the download-cache.
parent f5cbccff
...@@ -31,6 +31,7 @@ import setuptools.command.easy_install ...@@ -31,6 +31,7 @@ import setuptools.command.easy_install
import setuptools.command.setopt import setuptools.command.setopt
import setuptools.package_index import setuptools.package_index
import shutil import shutil
import socket
import stat import stat
import subprocess import subprocess
import sys import sys
...@@ -151,6 +152,19 @@ class AllowHostsPackageIndex(setuptools.package_index.PackageIndex): ...@@ -151,6 +152,19 @@ class AllowHostsPackageIndex(setuptools.package_index.PackageIndex):
self._current_requirement = str(requirement) self._current_requirement = str(requirement)
return super(AllowHostsPackageIndex, self).find_packages(requirement) return super(AllowHostsPackageIndex, self).find_packages(requirement)
def open_url(self, url, warning=None):
# setuptools (or urllib?) bug: There are already so many exceptions
# catched, like socket errors (e.g. failure in name resolution) or
# HTTP errors. Depending on when a timeout occurs, it is either catched
# (URLError during the SSL handshake) or not (socket.error while
# getting a HTTP response).
try:
return super(AllowHostsPackageIndex, self).open_url(url, warning)
except socket.error, e:
if not warning:
raise
self.warn(warning, e)
def process_url(self, url, retrieve=False): def process_url(self, url, retrieve=False):
"""Evaluate a URL as a possible download, and maybe retrieve it""" """Evaluate a URL as a possible download, and maybe retrieve it"""
if url in self.scanned_urls and not retrieve: if url in self.scanned_urls and not retrieve:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment