1717
1818import contextlib
1919import logging
20+ from datetime import timedelta
2021from typing import Annotated , Any , Final
2122
2223import networkx as nx
8485from ..dependencies .rut_client import get_rut_client
8586from .computations_tasks import analyze_pipeline
8687
87- _PIPELINE_ABORT_TIMEOUT_S : Final [int ] = 10
88+ _PIPELINE_ABORT_TIMEOUT_S : Final [timedelta ] = timedelta ( seconds = 30 )
8889
8990_logger = logging .getLogger (__name__ )
9091
@@ -121,7 +122,7 @@ async def _check_pipeline_startable(
121122 ):
122123 raise HTTPException (
123124 status_code = status .HTTP_406_NOT_ACCEPTABLE ,
124- detail = f"Project { computation .project_id } cannot run since it contains deprecated tasks { jsonable_encoder ( deprecated_tasks )} " ,
125+ detail = f"Project { computation .project_id } cannot run since it contains deprecated tasks { jsonable_encoder (deprecated_tasks )} " ,
125126 )
126127
127128
@@ -624,7 +625,7 @@ def return_last_value(retry_state: Any) -> Any:
624625 return retry_state .outcome .result ()
625626
626627 @retry (
627- stop = stop_after_delay (_PIPELINE_ABORT_TIMEOUT_S ),
628+ stop = stop_after_delay (_PIPELINE_ABORT_TIMEOUT_S . total_seconds () ),
628629 wait = wait_random (0 , 2 ),
629630 retry_error_callback = return_last_value ,
630631 retry = retry_if_result (lambda result : result is False ),
@@ -643,7 +644,7 @@ async def check_pipeline_stopped() -> bool:
643644 # wait for the pipeline to be stopped
644645 if not await check_pipeline_stopped ():
645646 _logger .error (
646- "pipeline %s could not be stopped properly after %ss " ,
647+ "pipeline %s could not be stopped properly after %s " ,
647648 project_id ,
648649 _PIPELINE_ABORT_TIMEOUT_S ,
649650 )
0 commit comments