async indexing, fixes
authorMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Thu, 27 Oct 2011 14:11:23 +0000 (16:11 +0200)
committerMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Tue, 15 Nov 2011 13:24:21 +0000 (14:24 +0100)
apps/search/index.py

index f5489a5..60e76a2 100644 (file)
@@ -82,6 +82,7 @@ class Index(IndexStore):
     def index_book(self, book, overwrite=True):
         if overwrite:
             self.remove_book(book)
     def index_book(self, book, overwrite=True):
         if overwrite:
             self.remove_book(book)
+            
 
         doc = self.extract_metadata(book)
         parts = self.extract_content(book)
 
         doc = self.extract_metadata(book)
         parts = self.extract_content(book)
@@ -263,19 +264,15 @@ class ReusableIndex(Index):
             atexit.register(ReusableIndex.close_reusable)
 
     def index_book(self, *args, **kw):
             atexit.register(ReusableIndex.close_reusable)
 
     def index_book(self, *args, **kw):
-        job = ReusableIndex.pool.apply_async(Index.index_book, args, kw)
+        job = ReusableIndex.pool.apply_async(Index.index_book, (self,)+ args, kw)
         ReusableIndex.pool_jobs.append(job)
 
     @staticmethod
     def close_reusable():
         ReusableIndex.pool_jobs.append(job)
 
     @staticmethod
     def close_reusable():
+        import pdb; pdb.set_trace()
         if ReusableIndex.index is not None:
         if ReusableIndex.index is not None:
-            all_jobs = len(ReusableIndex.pool_jobs)
-            waited=1
             for job in ReusableIndex.pool_jobs:
             for job in ReusableIndex.pool_jobs:
-                sys.stdout.write("\rWaiting for search index job: %d/%d..." % 
                 job.wait()
                 job.wait()
-                waited+=1
-            print("Indexing done.")
             ReusableIndex.pool.close()
 
             ReusableIndex.index.optimize()
             ReusableIndex.pool.close()
 
             ReusableIndex.index.optimize()