Merge pull request #891 from YanSte/lock

added lock
This commit is contained in:
Yannick Stephan
2025-02-20 00:21:28 +01:00
committed by GitHub

View File

@@ -7,7 +7,7 @@ from dataclasses import asdict, dataclass, field
from datetime import datetime
from functools import partial
from typing import Any, AsyncIterator, Callable, Iterator, cast
from asyncio import Lock
from .base import (
BaseGraphStorage,
BaseKVStorage,
@@ -358,6 +358,9 @@ class LightRAG:
convert_response_to_json
)
# Lock for entity extraction
_entity_lock = Lock()
# Custom Chunking Function
chunking_func: Callable[
[
@@ -824,7 +827,6 @@ class LightRAG:
self.tiktoken_model_name,
)
}
# Process document (text chunks and full docs) in parallel
tasks = [
self.doc_status.upsert(
@@ -897,6 +899,7 @@ class LightRAG:
if new_kg is None:
logger.info("No new entities or relationships extracted.")
else:
async with self._entity_lock:
logger.info("New entities or relationships extracted.")
self.chunk_entity_relation_graph = new_kg