From 23819beca552b4ca6b368e4eff50b956223e6a6b Mon Sep 17 00:00:00 2001 From: James Braza Date: Tue, 22 Oct 2024 15:40:02 -0700 Subject: [PATCH] Added writer.wait_merging_threads call to indexing process --- paperqa/agents/search.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/paperqa/agents/search.py b/paperqa/agents/search.py index 253ea078..e50eee0d 100644 --- a/paperqa/agents/search.py +++ b/paperqa/agents/search.py @@ -248,6 +248,7 @@ async def _add_document() -> None: writer: IndexWriter = (await self.index).writer() writer.add_document(Document.from_dict(index_doc)) # type: ignore[call-arg] writer.commit() + writer.wait_merging_threads() filehash = self.filehash(index_doc["body"]) (await self.index_files)[index_doc["file_location"]] = filehash @@ -287,6 +288,7 @@ def delete_document(index: Index, file_location: str) -> None: writer: IndexWriter = index.writer() writer.delete_documents("file_location", file_location) writer.commit() + writer.wait_merging_threads() except ValueError as e: if "Failed to acquire Lockfile: LockBusy." in str(e): raise AsyncRetryError("Failed to acquire lock") from e