As you can read here:
http://whoosh.readthedocs.io/en/latest/threads.html
Only one writer can hold lock. Buffered writer, keeps your data for sometime, but... at some point your objects are stored, and that mean - lock.
According to that document async writer is something that you are looking for, but... That would try to store your data, if fails - it will create additional thread, and retry. Let's suppose you are throwing 1000 new items. Potentially you will end up with something like 1000 threads. It can be better to treat each insert as a task, and send it to separate thread. If there are many processes, you can stack that tasks. For instance - insert 10, and wait. If that 10 are inserted as a batch, in short time? Will work - for some time...
Edit
Sample with async reader - to make buffered - simply rename import, and usage.
import os, os.path
from whoosh import index
from whoosh.fields import SchemaClass, TEXT, KEYWORD, ID
if not os.path.exists("data"):
os.mkdir("data")
# http://whoosh.readthedocs.io/en/latest/schema.html
class MySchema(SchemaClass):
path = ID(stored=True)
title = TEXT(stored=True)
icon = TEXT
content = TEXT(stored=True)
tags = KEYWORD
# http://whoosh.readthedocs.io/en/latest/indexing.html
ix = index.create_in("data", MySchema, indexname="myindex")
writer = ix.writer()
writer.add_document(title=u"My document", content=u"This is my document!",
path=u"/a", tags=u"first short", icon=u"/icons/star.png")
writer.add_document(title=u"Second try", content=u"This is the second example.",
path=u"/b", tags=u"second short", icon=u"/icons/sheep.png")
writer.add_document(title=u"Third time's the charm", content=u"Examples are many.",
path=u"/c", tags=u"short", icon=u"/icons/book.png")
writer.commit()
# needed to release lock
ix.close()
#http://whoosh.readthedocs.io/en/latest/api/writing.html#whoosh.writing.AsyncWriter
from whoosh.writing import AsyncWriter
ix = index.open_dir("data", indexname="myindex")
writer = AsyncWriter(ix)
writer.add_document(title=u"My document no 4", content=u"This is my document!",
path=u"/a", tags=u"four short", icon=u"/icons/star.png")
writer.add_document(title=u"5th try", content=u"This is the second example.",
path=u"/b", tags=u"5 short", icon=u"/icons/sheep.png")
writer.add_document(title=u"Number six is coming", content=u"Examples are many.",
path=u"/c", tags=u"short", icon=u"/icons/book.png")
writer.commit()