https://prefect.io logo
f

Fabrice Toussaint

03/07/2022, 9:36 AM
Hi all, Is it possible to cancel a flow after it ran for an X amount of time? Let's say I want to cancel flows that take longer than 1 hour? How would I approach this?
t

Tomer Cagan

03/07/2022, 9:47 AM
Seems there's a timeout argument - from https://docs.prefect.io/api/latest/core/task.html: • `timeout (Union[int, timedelta], optional)`: The amount of time (in seconds) to wait while running this task before a timeout occurs; note that sub-second resolution is not supported, even when passing in a timedelta.
f

Fabrice Toussaint

03/07/2022, 9:56 AM
Hi @Tomer Cagan thank you for your answer! The link you send is focused on a task and not on a flow. I want to be able to cancel a flow after it has surpassed 1 hour (for example by running another flow who checks active flows and then cancels the ones that are running for over an hour).
I found a way to do it, I am just retrieving the running flows from GraphQL and handle the rest with Python
t

Tomer Cagan

03/07/2022, 11:12 AM
Ah, I see now I misread the question!
k

Kevin Kho

03/07/2022, 2:04 PM
This is a Prefect Cloud feature called automations. It’s not in server but yes you can do something that works with the GraphQL API