[etwist, modconcat] closes #1806935: directly write data, don't put the whole concatenated thing in memory
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 05 Jul 2011 14:49:17 +0200
changeset 7620 bc2d690b97bf
parent 7619 0d0344fd5231
child 7622 36126858405f
[etwist, modconcat] closes #1806935: directly write data, don't put the whole concatenated thing in memory
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):
         """