From 5e2cd8f6f49601514de7b50c7e32ad8a0228b176 Mon Sep 17 00:00:00 2001 From: Benjamin Saller Date: Wed, 01 Aug 2007 01:23:43 +0000 Subject: workaround for lack of close() on xapian database. Its tied to the C++ dtor. This forces Python gc() to collect on the objects which in turn releases the C++ objects and forces db shutdown. It looks to be the best I can do now. --- diff --git a/src/olpc/datastore/xapianindex.py b/src/olpc/datastore/xapianindex.py index 671035d..d653f0e 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 re import sys @@ -106,7 +107,15 @@ class IndexManager(object): 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 diff --git a/tests/mountpoints.txt b/tests/mountpoints.txt index 45a359a..dbbf033 100644 --- a/tests/mountpoints.txt +++ b/tests/mountpoints.txt @@ -197,5 +197,4 @@ verify that we can still remount the store. >>> mp = ds.mountpoints[mp3] >>> assert mp.descriptor()['title'] == 'Fake USB from broken' - >>> ds.stop(); del ds -- cgit v0.9.1