Aj Floersch
03/14/2025, 2:55 PM@task
async def hanging_task():
await asyncio.sleep(30)
print("Finally finished.")
@flow(timeout_seconds=10)
async def impatient_flow():
await hanging_task()
# The above task completes before the flow will terminated due to timeout.
# The below never prints as expected.
print("Task completed without timeout.")
Marvin
03/14/2025, 2:55 PMhanging_task
completes before the flow is terminated due to the timeout. The flow timeout acts at the level of the entire flow execution, not on individual tasks.
For more details, you can refer to the Prefect documentation on cancellation and timeouts.
If you want to enforce a timeout on individual tasks, you might need to handle it within the task itself or use task-specific timeout mechanisms.