Christian Juhl
11/11/2022, 12:30 PMfrom prefect import task, flow, get_run_logger
@task
def square_number(number):
return number ** 2
@flow
def my_flow():
squared_numbers = []
for i in range(5):
result = square_number.submit(i)
squared_numbers.append(result.result())
return squared_numbers
if __name__ == '__main__':
output = my_flow()
print(output)
In this example, the next task is not submitted until the previous completes (they don't run concurrently), but if I move append(result.result()) outside the for loop, only the result from the last task is returned.
Thanks!Christopher Boyd
11/11/2022, 4:49 PMChristian Juhl
11/12/2022, 11:03 AM