Title: [commits] (vajda) [11186] - added optional 'wait' argument to Repository.notifyIndexer()
Revision
11186
Author
vajda
Date
2006-07-18 08:37:50 -0700 (Tue, 18 Jul 2006)

Log Message

- added optional 'wait' argument to Repository.notifyIndexer()
- fixed bug 6143
(http://bugzilla.osafoundation.org/show_bug.cgi?id=6143)
(Search is a bit random)

Modified Paths

Diff

Modified: trunk/chandler/parcels/osaf/views/main/Main.py (11185 => 11186)

--- trunk/chandler/parcels/osaf/views/main/Main.py	2006-07-18 13:46:29 UTC (rev 11185)
+++ trunk/chandler/parcels/osaf/views/main/Main.py	2006-07-18 15:37:50 UTC (rev 11186)
@@ -779,7 +779,10 @@
     def searchFor(self, query):
         if query:
             view = self.itsView
-            view.commit() # make sure all changes are searchable
+
+            # make sure all changes are searchable
+            view.commit()
+            view.repository.notifyIndexer(True)
             
             searchResults = view.searchItems(query)
 

Modified: trunk/chandler/repository/persistence/DBRepository.py (11185 => 11186)

--- trunk/chandler/repository/persistence/DBRepository.py	2006-07-18 13:46:29 UTC (rev 11185)
+++ trunk/chandler/repository/persistence/DBRepository.py	2006-07-18 15:37:50 UTC (rev 11186)
@@ -597,10 +597,10 @@
             self._indexer.terminate()
             self._indexer = None
 
-    def notifyIndexer(self):
+    def notifyIndexer(self, wait=False):
 
         if self._indexer is not None:
-            self._indexer.notify()
+            self._indexer.notify(wait)
 
     openUUID = UUID('c54211ac-131a-11d9-8475-000393db837c')
     OPEN_FLAGS = (DBEnv.DB_INIT_MPOOL | DBEnv.DB_INIT_LOCK |
@@ -1115,19 +1115,24 @@
                 condition.wait(60.0)
             condition.release()
 
-            if not (self._alive and self.isAlive()):
-                break
+            try:
+                if not (self._alive and self.isAlive()):
+                    break
 
-            latestVersion = store.getVersion()
-            indexVersion = store.getIndexVersion()
+                latestVersion = store.getVersion()
+                indexVersion = store.getIndexVersion()
 
-            if indexVersion < latestVersion:
-                if view is None:
-                    view = repository.createView("Lucene")
-                while indexVersion < latestVersion:
-                    view.refresh(version=indexVersion + 1, notify=False)
-                    self._indexVersion(view, indexVersion + 1, store)
-                    indexVersion += 1
+                if indexVersion < latestVersion:
+                    if view is None:
+                        view = repository.createView("Lucene")
+                    while indexVersion < latestVersion:
+                        view.refresh(version=indexVersion + 1, notify=False)
+                        self._indexVersion(view, indexVersion + 1, store)
+                        indexVersion += 1
+            finally:
+                condition.acquire()
+                condition.notifyAll()
+                condition.release()
 
         if view is not None:
             view.closeView()
@@ -1210,13 +1215,15 @@
                                                 uItem, uAttr, uValue, version)
                     store._values.c.setIndexed(store.txn, uValue)
 
-    def notify(self):
+    def notify(self, wait=False):
 
         if self._alive and self.isAlive():
             condition = self._condition
 
             condition.acquire()
             condition.notify()
+            if wait:
+                condition.wait()
             condition.release()
 
     def terminate(self):

Modified: trunk/chandler/repository/persistence/RepositoryView.py (11185 => 11186)

--- trunk/chandler/repository/persistence/RepositoryView.py	2006-07-18 13:46:29 UTC (rev 11185)
+++ trunk/chandler/repository/persistence/RepositoryView.py	2006-07-18 15:37:50 UTC (rev 11186)
@@ -823,7 +823,7 @@
 
         return instance
 
-    def refresh(self, mergeFn=None, version=None):
+    def refresh(self, mergeFn=None, version=None, notify=True):
         """
         Refresh this view to the changes made in other views.
 
@@ -839,7 +839,8 @@
                also in this view are marked C{STALE} unless they're pinned
                in memory in which case they're refreshed in place.
             3. Change and history notifications from changes in other views
-               are dispatched after the merges succeeded.
+               are dispatched after the merges succeeded if C{notify} is
+               C{True}, the default.
             4. If the view's cache has reached a threshhold item count - at
                the moment 10,000 - the least-used items are removed from
                cache and pointers to them are marked C{STALE} such that the
@@ -848,7 +849,7 @@
         
         raise NotImplementedError, "%s.refresh" %(type(self))
 
-    def commit(self, mergeFn=None):
+    def commit(self, mergeFn=None, notify=True):
         """
         Commit all the changes made to items in this view.
 
@@ -858,7 +859,8 @@
             2. All changes made to items in the view are saved to
                persistent storage.
             3. Change and history notifications from the items committed
-               are dispatched after the transactions commits.
+               are dispatched after the transactions commits if C{notify} is
+               {True}, the default.
         """
         
         raise NotImplementedError, "%s.commit" %(type(self))




_______________________________________________
Commits mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to