very basic question --- how do I run a `Flow` with...
# prefect-getting-started
a
very basic question --- how do I run a
Flow
without it blocking?
Copy code
from prefect import flow, task
@task
def add(a, b):
    return a + b

@flow
def workflow(a, b, c):
    return add.submit(add.submit(a, b), c)

workflow(1, 2, 3)
this blocks until
workflow(1,2,3)
is complete, even when I assign a
task_runner
explicitly to the
@flow
n
hi @Andrew Rosen - right now, flows run on the main thread and cannot be submitted elsewhere - but… we currently have a PR open to change this. still hashing out the exact DX, but you will be able to submit one or many flows to run off the main thread / in a non blocking fashion
a
Thanks for the info, @Nate!! Why does a
Flow
have methods like
.is_completed()
though if it always is blocking, and how in practice do you run multiple `Flow`s concurrently? I think I am missing something fundamental here since I imagine users must be interested in parallelization of flows and not just tasks within a flow.
n
flows do not have such methods, states do, where states belong to FlowRun objects
👍 1
you’re free to asyncio gather flows, but that gather is blocking, unlike task.submit
👍 1
what we propose in the pr is more like submit but for flows
a
thanks! that makes sense. I'll monitor the PR and in the meantime, I can always submit flows via independent processes of course
upvote 1
and you're correct -- my mistake about the method
n
👍 run _deployment is a common albeit cumbersome workaround