File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed
services/director-v2/src/simcore_service_director_v2
dynamic_sidecar/scheduler/_core Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 3434 dynamic_services ,
3535 dynamic_sidecar ,
3636 instrumentation ,
37+ long_running_tasks ,
3738 notifier ,
3839 rabbitmq ,
3940 redis ,
@@ -220,6 +221,7 @@ def create_app( # noqa: C901, PLR0912
220221 dynamic_sidecar .setup (app )
221222 socketio .setup (app )
222223 notifier .setup (app )
224+ long_running_tasks .setup (app )
223225
224226 if (
225227 settings .DIRECTOR_V2_COMPUTATIONAL_BACKEND .COMPUTATIONAL_BACKEND_DASK_CLIENT_ENABLED
Original file line number Diff line number Diff line change 3535)
3636from servicelib .utils import limited_gather , logged_gather
3737from simcore_postgres_database .models .comp_tasks import NodeClass
38+ from simcore_service_director_v2 .modules .long_running_tasks import (
39+ get_client_long_running_manager ,
40+ )
3841from tenacity import RetryError , TryAgain
3942from tenacity .asyncio import AsyncRetrying
4043from tenacity .before_sleep import before_sleep_log
@@ -289,6 +292,16 @@ async def service_remove_sidecar_proxy_docker_networks_and_volumes(
289292 message = "finished removing resources" , percent = ProgressPercent (1 )
290293 )
291294
295+ await _cleanup_long_running_tasks (app , scheduler_data .node_uuid )
296+
297+
298+ async def _cleanup_long_running_tasks (app : FastAPI , node_id : NodeID ) -> None :
299+ clinet_long_running_manager = get_client_long_running_manager (app )
300+
301+ await clinet_long_running_manager .cleanup_store (
302+ clinet_long_running_manager .get_sidecar_namespace (node_id )
303+ )
304+
292305
293306async def attempt_pod_removal_and_data_saving (
294307 app : FastAPI , scheduler_data : SchedulerData
Original file line number Diff line number Diff line change 1+ from fastapi import FastAPI
2+ from servicelib .long_running_tasks .client_long_running_manager import (
3+ ClientLongRunningManager ,
4+ )
5+
6+
7+ def setup (app : FastAPI ):
8+ async def _on_startup () -> None :
9+ client_long_running_manager = app .state .client_long_running_manager = (
10+ ClientLongRunningManager (redis_settings = app .state .settings .REDIS )
11+ )
12+ await client_long_running_manager .setup ()
13+
14+ async def _on_shutdown () -> None :
15+ client_long_running_manager : ClientLongRunningManager = (
16+ app .state .client_long_running_manager
17+ )
18+ await client_long_running_manager .shutdown ()
19+
20+ app .add_event_handler ("startup" , _on_startup )
21+ app .add_event_handler ("shutdown" , _on_shutdown )
22+
23+
24+ def get_client_long_running_manager (app : FastAPI ) -> ClientLongRunningManager :
25+ assert isinstance (
26+ app .state .client_long_running_manager , ClientLongRunningManager
27+ ) # nosec
28+ return app .state .client_long_running_manager
You can’t perform that action at this time.
0 commit comments