[Checkins] SVN: Products.ZCatalog/trunk/ As part of each progress handler report, also do an automatic transaction savepoint, to give the ZODB cache a chance to do garbage collection.

Hano Schlichting cvs-admin at zope.org
Sat Apr 7 12:35:56 UTC 2012


Log message for revision 125065:
  As part of each progress handler report, also do an automatic transaction savepoint, to give the ZODB cache a chance to do garbage collection.
  

Changed:
  U   Products.ZCatalog/trunk/CHANGES.txt
  U   Products.ZCatalog/trunk/src/Products/ZCatalog/ProgressHandler.py

-=-
Modified: Products.ZCatalog/trunk/CHANGES.txt
===================================================================
--- Products.ZCatalog/trunk/CHANGES.txt	2012-04-07 12:22:12 UTC (rev 125064)
+++ Products.ZCatalog/trunk/CHANGES.txt	2012-04-07 12:35:52 UTC (rev 125065)
@@ -4,6 +4,9 @@
 3.0 (unreleased)
 ----------------
 
+- As part of each progress handler report, also do an automatic transaction
+  savepoint, to give the ZODB cache a chance to do garbage collection.
+
 - Added a `threshold` argument to the catalog's `addColumn` and `delColumn`
   methods and used it for a progress handler. Also optimized some of their
   internals.

Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/ProgressHandler.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/ProgressHandler.py	2012-04-07 12:22:12 UTC (rev 125064)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/ProgressHandler.py	2012-04-07 12:35:52 UTC (rev 125065)
@@ -15,6 +15,7 @@
 import time
 from logging import getLogger
 
+import transaction
 from DateTime.DateTime import DateTime
 from zope.interface import implements
 
@@ -31,9 +32,10 @@
     def __init__(self, steps=100):
         self._steps = steps
 
-    def init(self, ident, max):
+    def init(self, ident, max, savepoint=True):
         self._ident = ident
         self._max = max
+        self.savepoint = savepoint
         self._start = time.time()
         self.fp = sys.stdout
         self.output('Process started (%d objects to go)' % self._max)
@@ -48,6 +50,8 @@
     def report(self, current, *args, **kw):
         if current > 0:
             if current % self._steps == 0:
+                if self.savepoint:
+                    transaction.savepoint(optimistic=True)
                 seconds_so_far = time.time() - self._start
                 seconds_to_go = (seconds_so_far / current *
                                  (self._max - current))



More information about the checkins mailing list