diff --git a/lightrag/kg/shared_storage.py b/lightrag/kg/shared_storage.py index 2c42ce93..87318c07 100644 --- a/lightrag/kg/shared_storage.py +++ b/lightrag/kg/shared_storage.py @@ -1123,7 +1123,9 @@ def get_storage_lock(workspace: str = "", enable_logging: bool = False) -> Unifi workspace: Optional workspace identifier for namespace isolation. enable_logging: Enable lock operation logging. """ - return _get_workspace_lock("storage_lock", _storage_lock, workspace, enable_logging) + return _get_workspace_lock( + "storage_lock", _storage_lock, workspace, enable_logging + ) def get_pipeline_status_lock(workspace: str = "", enable_logging: bool = False) -> UnifiedLock: @@ -1133,7 +1135,9 @@ def get_pipeline_status_lock(workspace: str = "", enable_logging: bool = False) workspace: Optional workspace identifier for namespace isolation. enable_logging: Enable lock operation logging. """ - return _get_workspace_lock("pipeline_status_lock", _pipeline_status_lock, workspace, enable_logging) + return _get_workspace_lock( + "pipeline_status_lock", _pipeline_status_lock, workspace, enable_logging + ) def get_graph_db_lock(workspace: str = "", enable_logging: bool = False) -> UnifiedLock: @@ -1143,7 +1147,9 @@ def get_graph_db_lock(workspace: str = "", enable_logging: bool = False) -> Unif workspace: Optional workspace identifier for namespace isolation. enable_logging: Enable lock operation logging. """ - return _get_workspace_lock("graph_db_lock", _graph_db_lock, workspace, enable_logging) + return _get_workspace_lock( + "graph_db_lock", _graph_db_lock, workspace, enable_logging + ) def get_storage_keyed_lock( @@ -1158,14 +1164,18 @@ def get_storage_keyed_lock( return _storage_keyed_lock(namespace, keys, enable_logging=enable_logging) -def get_data_init_lock(workspace: str = "", enable_logging: bool = False) -> UnifiedLock: +def get_data_init_lock( + workspace: str = "", enable_logging: bool = False +) -> UnifiedLock: """Return unified data initialization lock for ensuring atomic data initialization. Args: workspace: Optional workspace identifier for namespace isolation. enable_logging: Enable lock operation logging. """ - return _get_workspace_lock("data_init_lock", _data_init_lock, workspace, enable_logging) + return _get_workspace_lock( + "data_init_lock", _data_init_lock, workspace, enable_logging + ) def cleanup_keyed_lock() -> Dict[str, Any]: diff --git a/tests/test_workspace_locks.py b/tests/test_workspace_locks.py index 63ee0326..4639bda5 100644 --- a/tests/test_workspace_locks.py +++ b/tests/test_workspace_locks.py @@ -195,6 +195,7 @@ def test_all_lock_functions_without_workspace(): @pytest.mark.asyncio async def test_concurrent_workspace_operations(): """Test that multiple workspaces can operate concurrently without blocking.""" + async def simulate_document_upload(workspace: str): start_time = time.time() lock = get_pipeline_status_lock(workspace=workspace)