Skip to content

Commit f5e778a

Browse files
committed
enables lock_with_notification
1 parent 5b00a5c commit f5e778a

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

services/web/server/src/simcore_service_webserver/projects/projects_api.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99
# pylint: disable=too-many-arguments
1010

11+
import contextlib
1112
import json
1213
import logging
1314
from collections import defaultdict
@@ -195,33 +196,32 @@ async def retrieve_and_notify_project_locked_state(
195196
await notify_project_state_update(app, project)
196197

197198

198-
# TODO: Once python 3.8 is in use this
199-
# @contextlib.asynccontextmanager
200-
# async def lock_with_notification(
201-
# app: web.Application,
202-
# project_uuid: str,
203-
# status: ProjectStatus,
204-
# user_id: int,
205-
# user_name: Dict[str, str],
206-
# notify_users: bool = True,
207-
# ):
208-
# try:
209-
# async with await lock_project(
210-
# app,
211-
# project_uuid,
212-
# status,
213-
# user_id,
214-
# user_name,
215-
# ):
216-
# if notify_users:
217-
# await retrieve_and_notify_project_locked_state(
218-
# user_id, project_uuid, app
219-
# )
220-
# yield
221-
222-
# finally:
223-
# if notify_users:
224-
# await retrieve_and_notify_project_locked_state(user_id, project_uuid, app)
199+
@contextlib.asynccontextmanager
200+
async def lock_with_notification(
201+
app: web.Application,
202+
project_uuid: str,
203+
status: ProjectStatus,
204+
user_id: int,
205+
user_name: Dict[str, str],
206+
notify_users: bool = True,
207+
):
208+
try:
209+
async with await lock_project(
210+
app,
211+
project_uuid,
212+
status,
213+
user_id,
214+
user_name,
215+
):
216+
if notify_users:
217+
await retrieve_and_notify_project_locked_state(
218+
user_id, project_uuid, app
219+
)
220+
yield
221+
222+
finally:
223+
if notify_users:
224+
await retrieve_and_notify_project_locked_state(user_id, project_uuid, app)
225225

226226

227227
async def remove_project_interactive_services(

0 commit comments

Comments
 (0)