From a298566d134ac6476558df1fba1eecb97ebf9914 Mon Sep 17 00:00:00 2001 From: ChillarAnand Date: Wed, 15 Sep 2021 16:42:11 +0530 Subject: [PATCH] fix: Use whoosh AsyncWriter to prevent write locks --- frappe/search/full_text_search.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frappe/search/full_text_search.py b/frappe/search/full_text_search.py index 104398b0ef..560ad55bf3 100644 --- a/frappe/search/full_text_search.py +++ b/frappe/search/full_text_search.py @@ -8,6 +8,8 @@ from whoosh.index import create_in, open_dir, EmptyIndexError from whoosh.fields import TEXT, ID, Schema from whoosh.qparser import MultifieldParser, FieldsPlugin, WildcardPlugin from whoosh.query import Prefix +from whoosh.writing import AsyncWriter + class FullTextSearch: """ Frappe Wrapper for Whoosh """ @@ -75,7 +77,7 @@ class FullTextSearch: ix = self.get_index() with ix.searcher(): - writer = ix.writer() + writer = AsyncWriter(ix) writer.delete_by_term(self.id, document[self.id]) writer.add_document(**document) writer.commit(optimize=True) @@ -135,4 +137,4 @@ class FullTextSearch: return out def get_index_path(index_name): - return frappe.get_site_path("indexes", index_name) \ No newline at end of file + return frappe.get_site_path("indexes", index_name)