Slackbot
05/05/2026, 7:16 AMMarvin
05/05/2026, 7:16 AMMarvin
05/05/2026, 7:16 AM.submit(), but then the flow function returned before those task futures were resolved.
In Prefect 3.x, .submit() returns a PrefectFuture. If your flow exits while that future is still running or pending, Prefect warns with:
Finished in state Pending() Please wait for all submitted tasks to complete before exiting your flow...
Why it happens
- You called my_task.submit(...)
- But you did not call .wait() or .result() on the returned future
- So the flow ended before Prefect had a chance to finish the submitted task(s)
Typical fix
If you do not need the task result:
python
from prefect import flow, task
@task
def say_hello(name):
print(f"Hello, {name}!")
@flow
def example_flow():
future = say_hello.submit("Marvin")
future.wait()
example_flow()
If you do need the result:
python
from prefect import flow, task
@task
def add(x, y):
return x + y
@flow
def example_flow():
future = add.submit(1, 2)
result = future.result()
print(result)
example_flow()
If you submit multiple tasks:
python
from prefect import flow, task
@task
def work(i):
print(i)
@flow
def example_flow():
futures = [work.submit(i) for i in range(5)]
for future in futures:
future.wait()
example_flow()
Common pattern that causes this error
python
@flow
def bad_flow():
my_task.submit()
# flow exits immediately here
What to check in your code
- Are you storing the return value of every .submit() call?
- Are you calling .wait() or .result() on all of them?
- Are you returning from the flow too early?
- If using loops/list comprehensions, are you waiting on the whole list of futures?
If you want, paste your flow code and I can point to the exact line causing it.Marvin
05/05/2026, 7:29 AM