File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
packages/service-library/src/servicelib/long_running_tasks Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 99
1010from common_library .async_tools import cancel_wait_task
1111from models_library .api_schemas_long_running_tasks .base import TaskProgress
12- from pydantic import PositiveFloat
12+ from pydantic import NonNegativeFloat , PositiveFloat
1313from settings_library .redis import RedisDatabase , RedisSettings
1414from tenacity import (
1515 AsyncRetrying ,
3939_CANCEL_TASKS_CHECK_INTERVAL : Final [datetime .timedelta ] = datetime .timedelta (seconds = 5 )
4040_STATUS_UPDATE_CHECK_INTERNAL : Final [datetime .timedelta ] = datetime .timedelta (seconds = 1 )
4141
42+ _TASK_REMOVAL_MAX_WAIT : Final [NonNegativeFloat ] = 60
43+ _TASK_REMOVAL_WAIT_CHECK_INTERVAL : Final [NonNegativeFloat ] = 0.1
44+
4245
4346RegisteredTaskName : TypeAlias = str
4447RedisNamespace : TypeAlias = str
@@ -405,10 +408,11 @@ async def remove_task(
405408
406409 await self ._tasks_data .delete_task_data (task_id )
407410
408- # wait for task to be completed
411+ # wait for task to be removed since it might not have been running
412+ # in this process
409413 async for attempt in AsyncRetrying (
410- wait = wait_fixed (0.1 ),
411- stop = stop_after_delay (10 ),
414+ wait = wait_fixed (_TASK_REMOVAL_WAIT_CHECK_INTERVAL ),
415+ stop = stop_after_delay (_TASK_REMOVAL_MAX_WAIT ),
412416 retry = retry_if_exception_type (TryAgain ),
413417 ):
414418 with attempt :
You can’t perform that action at this time.
0 commit comments