Hello, I’m working on a project using prefect, I would like to modify the task state inside the task code.
I have a situation where my task will be called every time an event occurs (like a callback) and checks on a value, if the value satisfies the requirements I want to set the state to “Success” and finish the task, but if the value doesn’t satisfy the requirements i want to NOT finish the task and that until the task set itself as “Success”.
Do you have any ideas on how to do it ?
It looks like you are looking for a way to run a while-loop until some condition is true, is that correct?
If so, there are several ways how you may approach it:
You may run any Python code in your flows, including a while loop e.g. You No Longer Need Two Separate Systems for Batch Processing and Streaming - Prefect
Hello, I’m not really looking to run a while loop, my problem is that I want the task to not finish until an event occurs, but without doing infinite loop (which is really heavy)
so you want to poll for some condition? Can you check the event-driven Discourse page I link? If this doesn’t help, can you explain a concrete business use case you have? It would be easier to help if you could explain the problem you are trying to solve