diff options
-rw-r--r-- | src/olpc/datastore/backingstore.py | 8 | ||||
-rw-r--r-- | src/olpc/datastore/xapianindex.py | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/olpc/datastore/backingstore.py b/src/olpc/datastore/backingstore.py index 724e7cc..2956811 100644 --- a/src/olpc/datastore/backingstore.py +++ b/src/olpc/datastore/backingstore.py @@ -470,6 +470,7 @@ class InplaceFileBackingStore(FileBackingStore): # now map/update the existing data into the indexes # but do it async self.walker = threading.Thread(target=self._walk) + self._runWalker = True self.walker.setDaemon(True) self.walker.start() @@ -489,6 +490,8 @@ class InplaceFileBackingStore(FileBackingStore): for fn in filenames: + # give the thread a chance to exit + if not self._runWalker: break # blacklist files # ignore conventionally hidden files if fn.startswith("."): continue @@ -587,8 +590,9 @@ class InplaceFileBackingStore(FileBackingStore): def stop(self): if self.walker and self.walker.isAlive(): - self.walker.join() - self.indexmanager.stop() + # XXX: just force the unmount, flush the index queue + self._runWalker = False + self.indexmanager.stop(force=True) def complete_indexing(self): if self.walker and self.walker.isAlive(): diff --git a/src/olpc/datastore/xapianindex.py b/src/olpc/datastore/xapianindex.py index d46e0c7..671035d 100644 --- a/src/olpc/datastore/xapianindex.py +++ b/src/olpc/datastore/xapianindex.py @@ -102,8 +102,8 @@ 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() @@ -118,6 +118,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 |