Skip to content

Commit 444d280

Browse files
committed
cleanup
1 parent 5e5820e commit 444d280

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_users.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66
import logging
7-
from collections.abc import AsyncIterator, Callable
7+
from collections.abc import AsyncIterator
88
from datetime import timedelta
99

1010
from aiohttp import web
@@ -20,8 +20,6 @@
2020

2121
_logger = logging.getLogger(__name__)
2222

23-
CleanupContextFunc = Callable[[web.Application], AsyncIterator[None]]
24-
2523

2624
async def notify_user_logout_all_sessions(
2725
app: web.Application, user_id: UserID

services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def setup_periodic_task(
2323
periodic_task_coro: The periodic task coroutine function (already decorated with @exclusive_periodic)
2424
"""
2525
# setup
26-
task_name = periodic_task_coro.__name__
26+
task_name = f"{periodic_task_coro.__module__}.{periodic_task_coro.__name__}"
2727

2828
task = asyncio.create_task(
2929
periodic_task_coro(),
@@ -32,6 +32,10 @@ async def setup_periodic_task(
3232

3333
# prevents premature garbage collection of the task
3434
app_task_key = f"tasks.{task_name}"
35+
if app_task_key in app:
36+
msg = f"Task {task_name} is already registered in the app state"
37+
raise ValueError(msg)
38+
3539
app[app_task_key] = task
3640

3741
yield

0 commit comments

Comments
 (0)