Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Saller <bcsaller@objectrealms.net>2007-08-01 01:23:43 (GMT)
committer Benjamin Saller <bcsaller@objectrealms.net>2007-08-01 01:23:43 (GMT)
commit5e2cd8f6f49601514de7b50c7e32ad8a0228b176 (patch)
tree6d84c8e2280b22f4a955533a680531bfed8bcb1b
parent4e5de6d9675e83afc6ba442a19a832f0f0e2abab (diff)
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.
-rw-r--r--src/olpc/datastore/xapianindex.py11
-rw-r--r--tests/mountpoints.txt1
2 files changed, 10 insertions, 2 deletions
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