Skip to content

Commit 05f0c7a

Browse files
committed
ensure notification error does not fail lock
1 parent 60c4397 commit 05f0c7a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import functools
2+
import logging
23
from collections.abc import Awaitable, Callable, Coroutine
34
from typing import Any, Final, ParamSpec, TypeVar
45

56
from models_library.projects import ProjectID
67
from models_library.projects_access import Owner
78
from models_library.projects_state import ProjectLocked, ProjectStatus
9+
from servicelib.logging_utils import log_catch
810

911
from ._client import RedisClientSDK
1012
from ._decorators import exclusive
1113
from ._errors import CouldNotAcquireLockError, ProjectLockError
1214

1315
_PROJECT_REDIS_LOCK_KEY: Final[str] = "project_lock:{}"
1416

17+
_logger = logging.getLogger(__name__)
1518

1619
P = ParamSpec("P")
1720
R = TypeVar("R")
@@ -59,7 +62,8 @@ async def _wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
5962
)
6063
async def _exclusive_func(*args, **kwargs) -> R:
6164
if notification_cb is not None:
62-
await notification_cb()
65+
with log_catch(_logger, reraise=False):
66+
await notification_cb()
6367
return await func(*args, **kwargs)
6468

6569
try:
@@ -70,7 +74,8 @@ async def _exclusive_func(*args, **kwargs) -> R:
7074
finally:
7175
# we are now unlocked
7276
if notification_cb is not None:
73-
await notification_cb()
77+
with log_catch(_logger, reraise=False):
78+
await notification_cb()
7479

7580
return _wrapper
7681

0 commit comments

Comments
 (0)