Skip to content

Commit

Permalink
As part of each progress handler report, also do an automatic transac…
Browse files Browse the repository at this point in the history
…tion savepoint, to give the ZODB cache a chance to do garbage collection.
  • Loading branch information
hannosch committed Apr 7, 2012
1 parent 7e8ba2e commit 873f6e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog
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.
Expand Down
6 changes: 5 additions & 1 deletion src/Products/ZCatalog/ProgressHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import time
from logging import getLogger

import transaction
from DateTime.DateTime import DateTime
from zope.interface import implements

Expand All @@ -31,9 +32,10 @@ class StdoutHandler(object):
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)
Expand All @@ -48,6 +50,8 @@ def finish(self):
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))
Expand Down

0 comments on commit 873f6e4

Please sign in to comment.