Refactor shared storage to support both single and multi-process modes

• Initialize storage based on worker count
• Remove redundant global variable checks
• Add explicit mutex initialization
• Centralize shared storage initialization
• Fix process/thread lock selection logic
This commit is contained in:
yangdx
2025-02-27 08:48:33 +08:00
parent 7436c06f6c
commit 7c237920b1
3 changed files with 43 additions and 59 deletions

View File

@@ -267,6 +267,9 @@ class LightRAG:
_storages_status: StoragesStatus = field(default=StoragesStatus.NOT_CREATED)
def __post_init__(self):
from lightrag.kg.shared_storage import initialize_share_data
initialize_share_data()
os.makedirs(os.path.dirname(self.log_file_path), exist_ok=True)
set_logger(self.log_file_path, self.log_level)
logger.info(f"Logger initialized for working directory: {self.working_dir}")