Hi All, Is there a mechanism to apply on a task so...
# ask-community
m
Hi All, Is there a mechanism to apply on a task so that we would know if a task (or every task if that matters) within a flow is stuck in a specific state for a prolonged amount of time?
k
Hey @Mehdi Nazari, not exactly but you could use a
timeout
on the task level. If using Prefect Cloud, you can use an automation to change the state after a certain amount of time (mark as failed or send a notification)
m
Thank @Kevin Kho, I have explored automations, but didn’t notice any config related to time! Can you be more specific with your recommended solution please?
k
It would be like this. This is not on an individual task but you can set the Automation to trigger a notification if a Flow is in a given state of a certain amount of time
m
I see, Flow SLA management are Standard and Enterprise features. We’re still evaluating the free, 10,000 run/month plan.
k
Ah yeah. Then I guess you can try
task(timeout=…)
and then use a state handler, but timeouts don’t work all the time.
👍 1
m
I’ve got another question @Kevin Kho, do you have examples where I can see how to configure a flow with a
While True:
condition in it? What are best practices?
k
So I think infinite loops or listeners like this are not best practice with Prefect because the recommendation is to used event-based triggers to create Flows but if you want to do this, I don’t think there is a best practice other than using it in your task. You can do it
m
Got it,
While True
in my case, is not particularly listening for an event to get triggered! This is our mechanism to go over millions of records in a storage (db) and process information. Would you be interested to take a look?
k
I think I know what you are saying. Yeah in this case, I think
while True:
in the task should work.
🙏 1
m
Great, Thank you. I’ll let you know how it works after my tests 🙂