使用Buildout时套接字超时

时间:2013-07-04 22:35:26

标签: python buildout pypi

我们正在使用Buildout作为在此处构建我们的软件包的方法,并且在尝试通过运行bin/buildout来下载鸡蛋时,我们总是会感到非常沮丧:

We have no distributions for python-dateutil that satisfies 'python-dateutil>=1.5'.
While:
  Installing python_section.
  Getting distribution for 'python-dateutil>=1.5'.

An internal error occured due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
  File "/vagrant/eggs/zc.buildout-2.1.1-py2.7.egg/zc/buildout/buildout.py", line 1921, in main
    getattr(buildout, command)(args)
  File "/vagrant/eggs/zc.buildout-2.1.1-py2.7.egg/zc/buildout/buildout.py", line 602, in install
    installed_files = self[part]._call(recipe.install)
  File "/vagrant/eggs/zc.buildout-2.1.1-py2.7.egg/zc/buildout/buildout.py", line 1356, in _call
    return f()
  File "/vagrant/eggs/zc.recipe.egg-2.0.0-py2.7.egg/zc/recipe/egg/egg.py", line 126, in install
    reqs, ws = self.working_set()
  File "/vagrant/eggs/zc.recipe.egg-2.0.0-py2.7.egg/zc/recipe/egg/egg.py", line 84, in working_set
    allow_hosts=self.allow_hosts)
  File "/vagrant/eggs/zc.buildout-2.1.1-py2.7.egg/zc/buildout/easy_install.py", line 782, in install
    return installer.install(specs, working_set)
  File "/vagrant/eggs/zc.buildout-2.1.1-py2.7.egg/zc/buildout/easy_install.py", line 626, in install
    for dist in self._get_dist(requirement, ws):
  File "/vagrant/eggs/zc.buildout-2.1.1-py2.7.egg/zc/buildout/easy_install.py", line 448, in _get_dist
    dist, avail = self._satisfied(requirement)
  File "/vagrant/eggs/zc.buildout-2.1.1-py2.7.egg/zc/buildout/easy_install.py", line 204, in _satisfied
    return None, self._obtain(req, source)
  File "/vagrant/eggs/zc.buildout-2.1.1-py2.7.egg/zc/buildout/easy_install.py", line 372, in _obtain
    if index.obtain(requirement) is None:
  File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 340, in obtain
    self.prescan(); self.find_packages(requirement)
  File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 325, in find_packages
    self.scan_url(self.index_url + requirement.unsafe_name+'/')
  File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 668, in scan_url
    self.process_url(url, True)
  File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 223, in process_url
    page = self.process_index(url, page)
  File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 300, in process_index
    self.scan_url(new_url)
  File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 668, in scan_url
    self.process_url(url, True)
  File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 201, in process_url
    f = self.open_url(url, "Download error on %s: %%s -- Some packages may not be found!" % url)
  File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 610, in open_url
    return open_with_auth(url)
  File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 753, in _socket_timeout
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/setuptools/package_index.py", line 779, in open_with_auth
    fp = urllib2.urlopen(request)
  File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 400, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 418, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1180, in do_open
    r = h.getresponse(buffering=True)
  File "/usr/lib/python2.7/httplib.py", line 1030, in getresponse
    response.begin()
  File "/usr/lib/python2.7/httplib.py", line 407, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python2.7/httplib.py", line 365, in _read_status
    line = self.fp.readline()
  File "/usr/lib/python2.7/socket.py", line 447, in readline
    data = self._sock.recv(self._rbufsize)
timeout: timed out

有没有办法防止这些超时?他们为什么会这样?

1 个答案:

答案 0 :(得分:1)

索引服务器无法响应,连接超时。例如,当PyPI关闭时会发生这种情况。默认情况下,索引服务器为http://pypi.python.org/simple,但您可以使用[buildout]选项index设置自己的索引服务器。

我们使用egg代理(使用collective.eggproxy设置)自动创建本地缓存,以避免此类问题。我们的扩建使用 服务器作为索引,代理将从PyPI下载任何丢失的包并在本地缓存它们。因此,对于我们过去使用的任何软件包,即使PyPI(暂时)关闭,我们也可以继续提供服务。