Commit fab50478 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Cache downloaded data in zc/buildout/buildout.py:_open() in memory to accelerate remote extends.

parent 9b573ab6
......@@ -28,6 +28,7 @@ except ImportError:
from collections import MutableMapping as DictMixin
import zc.buildout.configparser
from cStringIO import StringIO
import copy
import datetime
import distutils.errors
......@@ -1586,6 +1587,7 @@ def _default_globals():
return globals_defs
_open_download_cache = {}
def _open(base, filename, seen, dl_options, override, downloaded):
"""Open a configuration file and return the result as a dictionary,
......@@ -1615,8 +1617,14 @@ def _open(base, filename, seen, dl_options, override, downloaded):
base = os.path.dirname(filename)
else:
filename = base + '/' + filename
data = _open_download_cache.get(filename)
if data is None:
downloaded_filename, is_temp = download(filename)
fp = open(downloaded_filename)
data = file(downloaded_filename).read()
_open_download_cache[filename] = data
else:
is_temp = False
fp = StringIO(data)
base = filename[:filename.rfind('/')]
else:
filename = os.path.join(base, filename)
......
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