Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/debian/patches/1003_avoid_with_statement.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/1003_avoid_with_statement.patch')
-rw-r--r--debian/patches/1003_avoid_with_statement.patch96
1 files changed, 96 insertions, 0 deletions
diff --git a/debian/patches/1003_avoid_with_statement.patch b/debian/patches/1003_avoid_with_statement.patch
new file mode 100644
index 0000000..8e0f442
--- /dev/null
+++ b/debian/patches/1003_avoid_with_statement.patch
@@ -0,0 +1,96 @@
+diff --git a/src/olpc/datastore/xapianindex.py b/src/olpc/datastore/xapianindex.py
+index 888bd26..c2506cb 100644
+--- a/src/olpc/datastore/xapianindex.py
++++ b/src/olpc/datastore/xapianindex.py
+@@ -4,8 +4,6 @@ xapianindex
+ maintain indexes on content
+
+ """
+-from __future__ import with_statement
+-
+ __author__ = 'Benjamin Saller <bcsaller@objectrealms.net>'
+ __docformat__ = 'restructuredtext'
+ __copyright__ = 'Copyright ObjectRealms, LLC, 2007'
+@@ -173,7 +170,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 +183,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 +196,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 +220,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 +252,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 +283,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 +345,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
+