diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index 92337e6c6a..e5c6c406eb 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -11,7 +11,6 @@ from frappe.commands import get_site, pass_context from frappe.coverage import CodeCoverage from frappe.exceptions import SiteNotSpecifiedError from frappe.utils import cint, update_progress_bar -from frappe.utils.synchronization import filelock find_executable = which # backwards compatibility DATA_IMPORT_DEPRECATION = ( @@ -55,6 +54,7 @@ def build( ): "Compile JS and CSS source files" from frappe.build import bundle, download_frappe_assets + from frappe.utils.synchronization import filelock frappe.init("") diff --git a/frappe/migrate.py b/frappe/migrate.py index b36745e4cf..3241b14152 100644 --- a/frappe/migrate.py +++ b/frappe/migrate.py @@ -21,7 +21,6 @@ from frappe.search.website_search import build_index_for_all_routes from frappe.utils.connections import check_connection from frappe.utils.dashboard import sync_dashboards from frappe.utils.fixtures import sync_fixtures -from frappe.utils.synchronization import filelock from frappe.website.utils import clear_website_cache BENCH_START_MESSAGE = dedent( @@ -163,6 +162,8 @@ class SiteMigration: """Run Migrate operation on site specified. This method initializes and destroys connections to the site database. """ + from frappe.utils.synchronization import filelock + if site: frappe.init(site=site) frappe.connect() diff --git a/frappe/search/website_search.py b/frappe/search/website_search.py index e43286285b..9af827aaa8 100644 --- a/frappe/search/website_search.py +++ b/frappe/search/website_search.py @@ -9,7 +9,6 @@ from whoosh.fields import ID, TEXT, Schema import frappe from frappe.search.full_text_search import FullTextSearch from frappe.utils import set_request, update_progress_bar -from frappe.utils.synchronization import filelock from frappe.website.serve import get_response_content INDEX_NAME = "web_routes" @@ -141,7 +140,9 @@ def remove_document_from_index(path): return ws.remove_document_from_index(path) -@filelock("building_website_search") def build_index_for_all_routes(): - ws = WebsiteSearch(INDEX_NAME) - return ws.build() + from frappe.utils.synchronization import filelock + + with filelock("building_website_search"): + ws = WebsiteSearch(INDEX_NAME) + return ws.build()