Hi How to call outside flow from task. I am gett...
# ask-community
v
Hi How to call outside flow from task. I am getting error
k
Copy code
with Flow(..) as flow:
    create_flow_run(...)
if you need to use it outside a Flow, just do
Copy code
create_flow_run.run(...)
v
is it possible to call flow from task?
And Not working in while loop
k
If you want to use a task in another task, you have to call the .run() method explicitly but it’s not treated as a task. It’s just the Python underneath that is invoked.
What are you trying to do with the infinite loop? I would not recommend that because you should just spin up an infinite number of flow runs. I would put the infinite loop inside a task inside if you want an indefinitely running Flow.
But it’s not a pattern Prefect specifically supports
v
My requirement is streaming data processing Step : I will configure the One flow which is continuosly listening my API . If my API gives any reponses . It will trigger another flow where i will do some operation .
Initiate the another flow continuously like parallel process
k
What is your requirement for the latency? Because Prefect can’t really do this at below 1 minute level
v
yes . thaty i using while loop for listing . my problem is unable to initiate another flow from task
k
It’s primarily a batch orchestrator. Prefect 2.0 though will support this use case but it is still in technical preview
You can by calling
.run()
Copy code
@task
def some_task():
    create_flow_run.run(...)
but create_flow_run is not a task anymore. Just the Python under the hood
v
so i missed .run right?
k
In this example yes but just not it’s not a task anymore.
It wont get retries and state tracking
v
yes it working now