Matt Chaput avatar Matt Chaput committed 2275d1c

Don't queue an empty doc buffer in MpWriter. Fixes issue #245.

Comments (0)

Files changed (2)

src/whoosh/filedb/multiproc.py

     def _commit(self, mergetype, optimize, merge):
         try:
             # Index the remaining documents in the doc buffer
-            self._enqueue()
+            if self.docbuffer:
+                self._enqueue()
             # Tell the tasks to finish
             for task in self.tasks:
                 self.jobqueue.put(None)

tests/test_mpwriter.py

                     assert word in hit["a"].split()
 
 
+@skip_if(no_multi)
+def test_batchsize_eq_doccount():
+    from whoosh.filedb.multiproc import MpWriter
 
+    schema = fields.Schema(a=fields.KEYWORD(stored=True))
+    with TempIndex(schema) as ix:
+        with ix.writer(procs=4, batchsize=10) as w:
+            for i in xrange(10):
+                w.add_document(a=u(str(i)))
 
 
 
 
 
+
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.