fix: move filelock imports to functions (#19300)

This commit is contained in:
Ankush Menat 2022-12-15 15:21:31 +05:30 committed by GitHub
parent 9b2283092e
commit 8107781f1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View file

@ -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("")

View file

@ -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()

View file

@ -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()