mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 13:22:12 +00:00
Improve lock name to config_lock instead of search_index_lock
It is used to lock updates to all app config state, including processor
This commit is contained in:
@@ -64,29 +64,29 @@ def configure_server(config: FullConfig, regenerate: bool, search_type: Optional
|
|||||||
|
|
||||||
# Initialize Processor from Config
|
# Initialize Processor from Config
|
||||||
try:
|
try:
|
||||||
state.search_index_lock.acquire()
|
state.config_lock.acquire()
|
||||||
state.processor_config = configure_processor(state.config.processor)
|
state.processor_config = configure_processor(state.config.processor)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"🚨 Failed to configure processor")
|
logger.error(f"🚨 Failed to configure processor")
|
||||||
raise e
|
raise e
|
||||||
finally:
|
finally:
|
||||||
state.search_index_lock.release()
|
state.config_lock.release()
|
||||||
|
|
||||||
# Initialize Search Models from Config
|
# Initialize Search Models from Config
|
||||||
try:
|
try:
|
||||||
state.search_index_lock.acquire()
|
state.config_lock.acquire()
|
||||||
state.SearchType = configure_search_types(state.config)
|
state.SearchType = configure_search_types(state.config)
|
||||||
state.search_models = configure_search(state.search_models, state.config.search_type)
|
state.search_models = configure_search(state.search_models, state.config.search_type)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"🚨 Failed to configure search models")
|
logger.error(f"🚨 Failed to configure search models")
|
||||||
raise e
|
raise e
|
||||||
finally:
|
finally:
|
||||||
state.search_index_lock.release()
|
state.config_lock.release()
|
||||||
|
|
||||||
# Initialize Content from Config
|
# Initialize Content from Config
|
||||||
if state.search_models:
|
if state.search_models:
|
||||||
try:
|
try:
|
||||||
state.search_index_lock.acquire()
|
state.config_lock.acquire()
|
||||||
state.content_index = configure_content(
|
state.content_index = configure_content(
|
||||||
state.content_index, state.config.content_type, state.search_models, regenerate, search_type
|
state.content_index, state.config.content_type, state.search_models, regenerate, search_type
|
||||||
)
|
)
|
||||||
@@ -94,7 +94,7 @@ def configure_server(config: FullConfig, regenerate: bool, search_type: Optional
|
|||||||
logger.error(f"🚨 Failed to index content")
|
logger.error(f"🚨 Failed to index content")
|
||||||
raise e
|
raise e
|
||||||
finally:
|
finally:
|
||||||
state.search_index_lock.release()
|
state.config_lock.release()
|
||||||
|
|
||||||
|
|
||||||
def configure_routes(app):
|
def configure_routes(app):
|
||||||
@@ -114,7 +114,7 @@ if not state.demo:
|
|||||||
@schedule.repeat(schedule.every(61).minutes)
|
@schedule.repeat(schedule.every(61).minutes)
|
||||||
def update_search_index():
|
def update_search_index():
|
||||||
try:
|
try:
|
||||||
state.search_index_lock.acquire()
|
state.config_lock.acquire()
|
||||||
state.content_index = configure_content(
|
state.content_index = configure_content(
|
||||||
state.content_index, state.config.content_type, state.search_models, regenerate=False
|
state.content_index, state.config.content_type, state.search_models, regenerate=False
|
||||||
)
|
)
|
||||||
@@ -122,7 +122,7 @@ if not state.demo:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"🚨 Error updating content index via Scheduler: {e}")
|
logger.error(f"🚨 Error updating content index via Scheduler: {e}")
|
||||||
finally:
|
finally:
|
||||||
state.search_index_lock.release()
|
state.config_lock.release()
|
||||||
|
|
||||||
|
|
||||||
def configure_search_types(config: FullConfig):
|
def configure_search_types(config: FullConfig):
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ host: str = None
|
|||||||
port: int = None
|
port: int = None
|
||||||
cli_args: List[str] = None
|
cli_args: List[str] = None
|
||||||
query_cache = LRU()
|
query_cache = LRU()
|
||||||
search_index_lock = threading.Lock()
|
config_lock = threading.Lock()
|
||||||
SearchType = utils_config.SearchType
|
SearchType = utils_config.SearchType
|
||||||
telemetry: List[Dict[str, str]] = []
|
telemetry: List[Dict[str, str]] = []
|
||||||
previous_query: str = None
|
previous_query: str = None
|
||||||
|
|||||||
Reference in New Issue
Block a user