Skip to content

Commit abd060c

Browse files
committed
refactor
1 parent 03cb7bd commit abd060c

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

packages/service-library/src/servicelib/redis/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
CouldNotAcquireLockError,
66
CouldNotConnectToRedisError,
77
LockLostError,
8+
ProjectLockError,
89
)
910
from ._models import RedisManagerDBConfig
1011
from ._project_lock import (
1112
PROJECT_REDIS_LOCK_KEY,
12-
ProjectLockError,
1313
get_project_locked_state,
1414
is_project_locked,
1515
with_project_locked,

packages/service-library/src/servicelib/redis/_errors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from typing import TypeAlias
2+
3+
import redis.exceptions
14
from common_library.errors_classes import OsparcErrorMixin
25

36

@@ -19,3 +22,6 @@ class LockLostError(BaseRedisError):
1922
"TIP: check connection to Redis DBs or look for Synchronous "
2023
"code that might block the auto-extender task. Somehow the distributed lock disappeared!"
2124
)
25+
26+
27+
ProjectLockError: TypeAlias = redis.exceptions.LockError # NOTE: backwards compatible

packages/service-library/src/servicelib/redis/_project_lock.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import functools
22
from collections.abc import Callable, Coroutine
3-
from typing import Any, Final, ParamSpec, TypeAlias, TypeVar
3+
from typing import Any, Final, ParamSpec, TypeVar
44

5-
import redis
6-
import redis.exceptions
75
from models_library.projects import ProjectID
86
from models_library.projects_access import Owner
97
from models_library.projects_state import ProjectLocked, ProjectStatus
108

119
from . import CouldNotAcquireLockError, RedisClientSDK, exclusive
10+
from ._errors import ProjectLockError
1211

1312
PROJECT_REDIS_LOCK_KEY: Final[str] = "project_lock:{}"
1413

15-
ProjectLockError: TypeAlias = redis.exceptions.LockError
16-
1714

1815
P = ParamSpec("P")
1916
R = TypeVar("R")

0 commit comments

Comments
 (0)