diff options
author | Jonas Smedegaard <dr@jones.dk> | 2008-03-09 16:24:26 (GMT) |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2008-03-09 16:24:26 (GMT) |
commit | e0f711c6a3eb2ee2e2a7a8a42a90069ae7272c18 (patch) | |
tree | 58e2464aaa79238dbee7fe423facdaa4354330bb | |
parent | f39f9b0987db04a478de532b20dab17ff55baf03 (diff) |
* Patch xapianindex to manually acquire and release locks (not using
with construct), to support Python 2.4.
-rw-r--r-- | debian/changelog | 4 | ||||
-rw-r--r-- | src/olpc/datastore/xapianindex.py | 25 |
2 files changed, 23 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog index e5eb654..73e3d15 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,10 @@ sugar-datastore (0.8.0~git.13d354b-2) unstable; urgency=low * Patch converter, datatore and backingstore to nest try: except: in try: except: finally: constructs, to support Python 2.4. + * Patch xapianindex to manually acquire and release locks (not using + with construct), to support Python 2.4. - -- Jonas Smedegaard <dr@jones.dk> Sun, 09 Mar 2008 15:22:55 +0100 + -- Jonas Smedegaard <dr@jones.dk> Sun, 09 Mar 2008 17:24:15 +0100 sugar-datastore (0.8.0~git.13d354b-1) unstable; urgency=low diff --git a/src/olpc/datastore/xapianindex.py b/src/olpc/datastore/xapianindex.py index 888bd26..37fe721 100644 --- a/src/olpc/datastore/xapianindex.py +++ b/src/olpc/datastore/xapianindex.py @@ -173,7 +173,8 @@ class IndexManager(object): self.deltact += 1 if force or self.deltact > FLUSH_THRESHOLD: - with self._write_lock: + self._write_lock.acquire() + try: # TODO: Would be better to check if the device is present and # don't try to flush if it's not. @@ -185,6 +186,8 @@ class IndexManager(object): #self.read_index.reopen() self.deltact = 0 + finally: + self._write_lock.release() else: self._flush_timeout = gobject.timeout_add(FLUSH_TIMEOUT * 1000, self._flush_timeout_cb) @@ -196,13 +199,16 @@ class IndexManager(object): # conversion/fulltext indexing can # happen in the thread if operation in (CREATE, UPDATE): - with self._write_lock: + self._write_lock.acquire() + try: if operation is CREATE: self.write_index.add(doc) logger.info("created %s:%s" % (uid, vid)) elif operation is UPDATE: self.write_index.replace(doc) logger.info("updated %s:%s" % (uid, vid)) + finally: + self._write_lock.release() self.flush() # Disable content indexing for Trial-3. @@ -217,9 +223,12 @@ class IndexManager(object): return elif operation is DELETE: # sync deletes - with self._write_lock: + self._write_lock.acquire() + try: self.write_index.delete(uid) logger.info("deleted content %s:%s" % (uid,vid)) + finally: + self._write_lock.release() self.flush() return @@ -246,7 +255,8 @@ class IndexManager(object): continue try: - with self._write_lock: + self._write_lock.acquire() + try: if operation is UPDATE: # Here we handle the conversion of binary # documents to plain text for indexing. This is @@ -276,6 +286,8 @@ class IndexManager(object): # tell the queue its complete self.queue.task_done() + finally: + self._write_lock.release() # we do flush on each record now self.flush() @@ -336,8 +348,11 @@ class IndexManager(object): d[p.key] = p if add_anything: - with self._write_lock: + self._write_lock.acquire() + try: self.datamodel.apply(self) + finally: + self._write_lock.release() return d |