Guilins
01/10/2025, 6:32 PMA future was garbage collected before it resolved. Please call `.wait()` or `.result()` on futures to ensure they resolve.
See <https://docs.prefect.io/latest/develop/task-runners> for more details.
Marvin
01/10/2025, 6:32 PM.result()
or .wait()
. This ensures that the tasks complete and the results are available before the future is garbage collected. Here's a relevant link.
2. Concurrency Limits: You can manage the concurrency of task runs using global concurrency limits or task run concurrency limits with tags. This can help prevent too many tasks from running simultaneously and overwhelming resources. More details can be found here and here.
3. Task Runners: Ensure you are using the appropriate task runner for your setup. Prefect provides a ThreadPoolTaskRunner
which allows you to set max_workers
to control the number of concurrent tasks. This can be adjusted to better match your workload. Here's more information on task runners.
4. Common Gotchas: Remember that .map
and .submit
are synchronous in Prefect 3.x, and futures returned by .map
can be resolved together, such as using integers = double.map(range(10)).result()
.
If you need to maintain performance while ensuring futures are resolved, consider adjusting the concurrency settings and task runners to better suit your workload. If the issue persists, you might want to explore more advanced concurrency management techniques or consult the Prefect community for further guidance.