Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added writer.wait_merging_threads call #628

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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