|
8 | 8 | """
|
9 | 9 | # pylint: disable=too-many-arguments
|
10 | 10 |
|
| 11 | +import contextlib |
11 | 12 | import json
|
12 | 13 | import logging
|
13 | 14 | from collections import defaultdict
|
@@ -195,33 +196,32 @@ async def retrieve_and_notify_project_locked_state(
|
195 | 196 | await notify_project_state_update(app, project)
|
196 | 197 |
|
197 | 198 |
|
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) |
225 | 225 |
|
226 | 226 |
|
227 | 227 | async def remove_project_interactive_services(
|
|
0 commit comments