yangdx
commited on
Commit
·
ab86a1f
1
Parent(s):
8286847
fix: convert multiprocessing managed dict to normal dict before JSON dump
Browse files
lightrag/kg/json_doc_status_impl.py
CHANGED
@@ -83,9 +83,9 @@ class JsonDocStatusStorage(DocStatusStorage):
|
|
83 |
return result
|
84 |
|
85 |
async def index_done_callback(self) -> None:
|
86 |
-
# 文件写入需要加锁,防止多个进程同时写入导致文件损坏
|
87 |
with self._storage_lock:
|
88 |
-
|
|
|
89 |
|
90 |
async def upsert(self, data: dict[str, dict[str, Any]]) -> None:
|
91 |
logger.info(f"Inserting {len(data)} to {self.namespace}")
|
|
|
83 |
return result
|
84 |
|
85 |
async def index_done_callback(self) -> None:
|
|
|
86 |
with self._storage_lock:
|
87 |
+
data_dict = dict(self._data) if hasattr(self._data, "_getvalue") else self._data
|
88 |
+
write_json(data_dict, self._file_name)
|
89 |
|
90 |
async def upsert(self, data: dict[str, dict[str, Any]]) -> None:
|
91 |
logger.info(f"Inserting {len(data)} to {self.namespace}")
|
lightrag/kg/json_kv_impl.py
CHANGED
@@ -35,9 +35,9 @@ class JsonKVStorage(BaseKVStorage):
|
|
35 |
logger.info(f"Load KV {self.namespace} with {len(loaded_data)} data")
|
36 |
|
37 |
async def index_done_callback(self) -> None:
|
38 |
-
# 文件写入需要加锁,防止多个进程同时写入导致文件损坏
|
39 |
with self._storage_lock:
|
40 |
-
|
|
|
41 |
|
42 |
async def get_by_id(self, id: str) -> dict[str, Any] | None:
|
43 |
with self._storage_lock:
|
|
|
35 |
logger.info(f"Load KV {self.namespace} with {len(loaded_data)} data")
|
36 |
|
37 |
async def index_done_callback(self) -> None:
|
|
|
38 |
with self._storage_lock:
|
39 |
+
data_dict = dict(self._data) if hasattr(self._data, "_getvalue") else self._data
|
40 |
+
write_json(data_dict, self._file_name)
|
41 |
|
42 |
async def get_by_id(self, id: str) -> dict[str, Any] | None:
|
43 |
with self._storage_lock:
|