Does anybody have flows that act as infinite loops running the same tasks again and again instead of scheduling a flow to run every few seconds? Just wondering if there’s any downside to doing that vs. scheduling it.
a
Alexander Azzam
09/17/2024, 5:02 PM
ha! you're speaking @Chris White's love language. he's traveling so might be slow to respond but this has really been on his mind recently
c
Carlos Cueto
09/17/2024, 5:07 PM
Haha good to know. It seems to me that an infinite loop seems to be easier on the Prefect API and thus better with resources on the worker side. It’s especially useful when I don’t know the exact time the flow run will take to execute, so a set schedule doesn’t work out that well since it sometimes causes multiple flow runs to be Running at once, leading to backlogs. Running it sequentially in a “while: True” loop just starts the next iteration whenever the previous one finishes, so timing isn’t an issue.
a
Alexander Azzam
09/17/2024, 5:12 PM
yeah we've put a ton of thought recently in things like idempotency and caching so that your have tasks run in a big ole loop forever - cached - and then you can externally invalidate that cache if you want to have it do the real work
c
Chris White
09/18/2024, 6:36 AM
Haha yes! It’s a valid pattern, I think the only catch is that the assumption that flows terminate in some reasonable timeframe is baked into the UI in a lot of ways, so you might experience friction in that regard. In this case the flow is acting kind of like it’s own worker, and I wonder if there’s a way we could support that in a first class way 🧐
Chris White
09/18/2024, 6:36 AM
Could be worth starting a discussion on GitHub on the topic of “long running flows”
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.