https://prefect.io logo
Title
a

Anjaneyulu K

11/08/2022, 10:30 PM
Hi #prefect-cloud #prefect-getting-started, Got Runtime error as task runner is already started in below scenario
@flow(name="Status check")
def run():
    a= "hello"
    if(condition):
        success
    else:
        run()

if __name__ == "__main__":
   run()
Can anyone help. This is more like recursive funtion
j

James Sopkin

11/08/2022, 10:37 PM
Couldn’t you achieve this with a while loop? What would be the reason to recursively call a flow?
a

Anjaneyulu K

11/08/2022, 10:42 PM
@flow(name="Status check")
def run():
    a= task1 output

    if(task1 output condition):
        running other task2
    else:
       wait(10)
        run()
this is exact sudo code
I am checking status in time manner
@James Sopkin Cant use recursive
?
j

James Sopkin

11/08/2022, 11:50 PM
I don't believe it is possible to recursively call a flow. Could you try something like this?
@flow(name="Status check")
def run():
  a = task1()
  while a != condition:
     a = task1()
     wait(10)
  task2()
a

Anjaneyulu K

11/08/2022, 11:57 PM
I did the same . but it is repeated code. I think even I cant use nested task
j

James Sopkin

11/09/2022, 2:31 PM
Could you post the logs? I tried doing something similar and it works fine