Scott Stafford
01/19/2024, 4:12 PMMarvin
01/19/2024, 4:13 PM@task
decorator to turn it into a Prefect task.
2. Polling with Scheduled Runs: Instead of using sleep, schedule another task that will poll the status endpoint. This task needs to be invoked periodically based on your expected waiting time for the API task completion.
3. Conditional Execution: Use a condition to check the status from the status endpoint. On completion, trigger the next task.
4. State Dependence: Make sure your next task depends on the successful state of the polling task, ensuring the next task runs only after the long-running API task is complete.
Prefect 2.0 introduces a new concept called 'blocking tasks', which can be used to wait for the completion of an external event. However, since Prefect 2.0 and its detailed workings are out of my knowledge scope and we wouldn't want to guess and cause your flow to block indefinitely, I'd suggest looking up the official Prefect documentation or checking out GitHub issues to see any associated patterns or examples for accomplishing this without a constant loop.
Shall I go ahead and look for some specific examples that could guide you further?Scott Stafford
01/19/2024, 4:21 PMbrett
02/02/2024, 4:38 AM