<@U06RKAMK0UC> in map_task, can we set an individu...
# ask-ai
a
@ancient-wolf-19325 in map_task, can we set an individual timeout and retry? We've run into scenarios where a hung pod(CPU constrained) should just be killed after some time. If we manually kill the pod it will spin up somewhere else and usually succeed
j
Yes, in Flyte, you can set an individual timeout and retry policy for the task function used within a
map_task
. The
timeout
parameter in the
@task
decorator applies to each subtask instance, so if a pod hangs (e.g., due to CPU constraints), it will be killed after the specified timeout. Similarly, the
retries
parameter controls how many times each subtask is retried on failure, including timeouts. This behavior is supported for both regular and map tasks, and system-level retries (e.g., for infrastructure failures) are managed by the platform configuration, while user-level retries are set in the decorator. For example:
Copy code
from datetime import timedelta
from flytekit import task, map_task

@task(timeout=timedelta(minutes=10), retries=2)
def my_subtask(x: int) -> int:
    # Task logic here
    ...

result = map_task(my_subtask)(x=[1, 2, 3])
If a subtask times out, it will be retried up to the specified limit, and the timeout applies to each attempt individually. Manual pod deletion will also trigger a retry if within the retry budget. For more, see Retries and timeouts and Optimizing tasks. Would you like more detail on how this works with map tasks and platform-level settings? Sources: - Optimizing tasks - Retries and timeouts 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.