File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed
services/web/server/src/simcore_service_webserver/trash Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change 1+ import asyncio
12import logging
23
34from aiohttp import web
2021
2122_logger = logging .getLogger (__name__ )
2223
23- #
24- # EXCEPTIONS HANDLING
25- #
26-
2724
2825_TO_HTTP_ERROR_MAP : ExceptionToHttpErrorMap = {
2926 ProjectRunningConflictError : HttpErrorInfo (
4239)
4340
4441
45- #
46- # ROUTES
47- #
48-
4942routes = web .RouteTableDef ()
5043
5144
@@ -57,12 +50,24 @@ async def empty_trash(request: web.Request):
5750 user_id = get_user_id (request )
5851 product_name = get_product_name (request )
5952
60- fire_and_forget_task (
61- _service .safe_empty_trash (
53+ is_fired = asyncio .Event ()
54+
55+ async def _empty_trash ():
56+ is_fired .set ()
57+ await _service .safe_empty_trash (
6258 request .app , product_name = product_name , user_id = user_id
63- ),
59+ )
60+
61+ fire_and_forget_task (
62+ _empty_trash (),
6463 task_suffix_name = "rest.empty_trash" ,
6564 fire_and_forget_tasks_collection = request .app [APP_FIRE_AND_FORGET_TASKS_KEY ],
6665 )
6766
67+ # NOTE: Ensures `fire_and_forget_task` is triggered; otherwise,
68+ # when the front-end requests the trash item list,
69+ # it may still display items, misleading the user into
70+ # thinking the `empty trash` operation failed.
71+ await is_fired .wait ()
72+
6873 return web .json_response (status = status .HTTP_204_NO_CONTENT )
You can’t perform that action at this time.
0 commit comments