Commit c7f68ff0 authored by Jeremy Hylton's avatar Jeremy Hylton

Modify undoLog() to allow other threads to run periodically.

parent ef8e5a76
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
# may have a back pointer to a version record or to a non-version # may have a back pointer to a version record or to a non-version
# record. # record.
# #
__version__='$Revision: 1.99 $'[11:-2] __version__='$Revision: 1.100 $'[11:-2]
import base64 import base64
from cPickle import Pickler, Unpickler, loads from cPickle import Pickler, Unpickler, loads
...@@ -1091,14 +1091,20 @@ class FileStorage(BaseStorage.BaseStorage, ...@@ -1091,14 +1091,20 @@ class FileStorage(BaseStorage.BaseStorage,
us = UndoSearch(self._file, self._pos, self._packt, us = UndoSearch(self._file, self._pos, self._packt,
first, last, filter) first, last, filter)
while not us.finished(): while not us.finished():
# Hold lock for batches of 20 searches, so default search
# parameters will finish without letting another thread run.
for i in range(20):
if us.finished():
break
us.search() us.search()
# Give another thread a chance, so that a long undoLog()
# operation doesn't block all other activity.
self._lock_release()
self._lock_acquire()
return us.results return us.results
finally: finally:
self._lock_release() self._lock_release()
def undoFindNext(self, pos, result, first, i, filter):
pass
def transactionalUndo(self, transaction_id, transaction): def transactionalUndo(self, transaction_id, transaction):
"""Undo a transaction, given by transaction_id. """Undo a transaction, given by transaction_id.
......
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