Skip to content

Commit

Permalink
Added writer.wait_merging_threads call to indexing process
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbraza committed Oct 22, 2024
1 parent fc5d18a commit 23819be
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions paperqa/agents/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 23819be

Please sign in to comment.