# HG changeset patch # User Sylvain Thénault # Date 1309870157 -7200 # Node ID bc2d690b97bf73fb8aaaf4d243f05a8e40415db3 # Parent 0d0344fd523155f7cf6bfcf33bd4dc1b94788da9 [etwist, modconcat] closes #1806935: directly write data, don't put the whole concatenated thing in memory diff -r 0d0344fd5231 -r bc2d690b97bf etwist/server.py --- a/etwist/server.py Tue Jul 05 12:09:53 2011 +0200 +++ b/etwist/server.py Tue Jul 05 14:49:17 2011 +0200 @@ -191,20 +191,20 @@ def _concat_cached_filepath(self, filepath, paths): if not self._up_to_date(filepath, paths): - concat_data = [] - for path in paths: - dirpath, rid = self._resource(path) - if rid is None: - # In production mode log an error, do not return a 404 - # XXX the erroneous content is cached anyway - LOGGER.error('concatenated data url error: %r file ' - 'does not exist', path) - if self.config.debugmode: - raise ConcatFileNotFoundError(path) - else: - concat_data.append(open(osp.join(dirpath, rid)).read()) with open(filepath, 'wb') as f: - f.write('\n'.join(concat_data)) + for path in paths: + dirpath, rid = self._resource(path) + if rid is None: + # In production mode log an error, do not return a 404 + # XXX the erroneous content is cached anyway + LOGGER.error('concatenated data url error: %r file ' + 'does not exist', path) + if self.config.debugmode: + raise ConcatFileNotFoundError(path) + else: + for line in open(osp.join(dirpath, rid)): + f.write(line) + f.write('\n') def _up_to_date(self, filepath, paths): """