Andy Irvine
11/28/2024, 5:33 PMMarvin
11/28/2024, 5:34 PMtimeout_seconds
keyword argument when defining a task. This allows you to set a specific duration in seconds after which a task will timeout if it's still running.
Here's an example:
python
from prefect import task
@task(timeout_seconds=60)
def my_task():
# task logic here
In this case, if my_task
runs for more than 60 seconds, it will be terminated and marked as timed out. More details can be found here.
It's up to you to save your tasks from running indefinitely!Andy Irvine
11/28/2024, 5:39 PMFinished in state Failed('Flow run encountered an exception. TimeoutError: ')
01:23:28 PM
prefect.flow_runs
Encountered exception during execution:
Traceback (most recent call last):
File "/app/.venv/lib/python3.11/site-packages/prefect/engine.py", line 864, in orchestrate_flow_run
result = await flow_call.aresult()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 293, in aresult
return await asyncio.wrap_future(self.future)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError
Marvin
11/28/2024, 5:40 PM