<@ULVA73B9P> I'm running the following code: ```fr...
# ask-marvin
g
@Marvin I'm running the following code:
Copy code
from prefect import flow, task
from prefect.futures import wait

@task
def download_panel() -> None:
    raise RuntimeError("Download failed")

@task
def prepare_panel():
    logger.info("Preparing panel")

@flow
def glimpse_prep_workflow():
    task_download = download_panel.submit()
    task_prepare = prepare_panel.submit(wait_for=[task_download])

    wait([task_download, task_prepare])
When running this, I get the following output:
Copy code
Please wait for all submitted tasks to complete before exiting your flow by calling `.wait()` on the `PrefectFuture` returned from your `.submit()` calls.

Example:

from prefect import flow, task

@task
def say_hello(name):
    print(f"Hello, {name}!")

@flow
def example_flow():
    future = say_hello.submit(name="Marvin")
    future.wait()

example_flow()
Since I did call
wait
, the warning and example seem to be superfluous. Is this a bug in my code, or in Prefect's?
m
Your message was too long by 602 tokens...
Your message was too long by 222 tokens...
Your message was too long by 132 tokens...
Your message was too long by 79 tokens...
The warning you're encountering is related to how Prefect 3.x handles
PrefectFuture
objects. In Prefect 3.x, tasks submitted using
.submit()
return
PrefectFuture
objects, which need to be explicitly waited upon using
.wait()
or
.result()
. The warning is triggered when a
PrefectFuture
is garbage collected without being resolved, which can lead to task run failures if the flow exits prematurely. Here's what you need to know: 1. Explicit Waiting: Each
PrefectFuture
must be explicitly resolved using
.wait()
or
.result()
. Your code seems to be following this pattern, but the warning suggests that Prefect might not recognize it due to the order or manner of execution. 2. Ensure Proper Resolution: Make sure that the
wait()
method is called directly on each
PrefectFuture
object. It might be helpful to call
.wait()
directly on the future objects, rather than using the
wait
function from
prefect.futures
. 3. Potential Bug or Edge Case: If you are certain that your code is correctly waiting on all futures, this might be an edge case or bug in Prefect. It's worth checking the latest updates or issues on Prefect's GitHub repository for any related reports. For more information on handling
PrefectFuture
and resolving these warnings, refer to the Prefect 3.x documentation: - Task Runners and Prefect Futures If the problem persists, consider raising an issue with a detailed description and reproduction steps in the Prefect GitHub repository.