diff --git a/packages/service-library/src/servicelib/redis_utils.py b/packages/service-library/src/servicelib/redis_utils.py index 82d1812c0ee..32753ec16ed 100644 --- a/packages/service-library/src/servicelib/redis_utils.py +++ b/packages/service-library/src/servicelib/redis_utils.py @@ -69,7 +69,8 @@ def start_exclusive_periodic_task( redis: RedisClientSDK, task: Callable[..., Awaitable[None]], *, - interval: timedelta, + task_period: timedelta, + retry_after: timedelta = timedelta(seconds=1), task_name: str, **kwargs, ) -> asyncio.Task: @@ -91,11 +92,11 @@ def start_exclusive_periodic_task( """ return start_periodic_task( _exclusive_task_starter, - interval=interval, + interval=retry_after, task_name=f"exclusive_task_starter_{task_name}", redis=redis, usr_tsk_task=task, - usr_tsk_interval=timedelta(seconds=1), + usr_tsk_interval=task_period, usr_tsk_task_name=task_name, **kwargs, ) diff --git a/packages/service-library/tests/test_redis_utils.py b/packages/service-library/tests/test_redis_utils.py index 169b4ba3fd9..bf50cd6fc25 100644 --- a/packages/service-library/tests/test_redis_utils.py +++ b/packages/service-library/tests/test_redis_utils.py @@ -124,7 +124,7 @@ async def _assert_task_completes_once( started_task = start_exclusive_periodic_task( redis_client_sdk, _sleep_task, - interval=timedelta(seconds=1), + task_period=timedelta(seconds=1), task_name="long_running", sleep_interval=1, on_sleep_events=sleep_events, diff --git a/services/resource-usage-tracker/src/simcore_service_resource_usage_tracker/resource_tracker.py b/services/resource-usage-tracker/src/simcore_service_resource_usage_tracker/resource_tracker.py index 27ef7867b26..6bee4c87add 100644 --- a/services/resource-usage-tracker/src/simcore_service_resource_usage_tracker/resource_tracker.py +++ b/services/resource-usage-tracker/src/simcore_service_resource_usage_tracker/resource_tracker.py @@ -57,7 +57,8 @@ async def _startup() -> None: app.state.resource_tracker_background_task = start_exclusive_periodic_task( get_redis_client(app), periodic_check_of_running_services_task, - interval=app_settings.RESOURCE_USAGE_TRACKER_MISSED_HEARTBEAT_INTERVAL_SEC, + task_period=app_settings.RESOURCE_USAGE_TRACKER_MISSED_HEARTBEAT_INTERVAL_SEC, + retry_after=app_settings.RESOURCE_USAGE_TRACKER_MISSED_HEARTBEAT_INTERVAL_SEC, task_name=_TASK_NAME_PERIODICALY_CHECK_RUNNING_SERVICES, app=app, )