diff options
Diffstat (limited to 'src/olpc/datastore/xapianindex.py')
-rw-r--r-- | src/olpc/datastore/xapianindex.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/olpc/datastore/xapianindex.py b/src/olpc/datastore/xapianindex.py index 4212ad3..ceb7d56 100644 --- a/src/olpc/datastore/xapianindex.py +++ b/src/olpc/datastore/xapianindex.py @@ -14,6 +14,7 @@ __license__ = 'The GNU Public License V2+' from Queue import Queue, Empty +import gc import logging import os import re @@ -104,11 +105,19 @@ class IndexManager(object): self.backingstore = backingstore - def stop(self): - self.stopIndexer() + def stop(self, force=False): + self.stopIndexer(force) self.write_index.close() self.read_index.close() - + # XXX: work around for xapian not having close() this will + # change in the future in the meantime we delete the + # references to the indexers and then force the gc() to run + # which should inturn trigger the C++ destructor which forces + # the database shut. + self.write_index = None + self.read_index = None + gc.collect() + # Index thread management def startIndexer(self): self.indexer_running = True @@ -120,6 +129,7 @@ class IndexManager(object): if not self.indexer_running: return if not force: self.queue.join() self.indexer_running = False + # should terminate after the current task self.indexer.join() # flow control |