Skip to content

distributed.client.FutureCancelledError when computing a da.from_delayed(future) when future goes out of scope. #9050

@TomAugspurger

Description

@TomAugspurger

Describe the issue:

This seems similar to #9041, which was fixed by dask/dask#11886, but for arrays. It started failing with dask/dask@0194ef4 / dask/dask#11881.

Minimal Complete Verifiable Example:

from distributed import Client
import dask.array as da
import numpy as np


def main():
    arr = np.zeros((10, 10))
    meta = arr[:0, :0]

    with Client(n_workers=2) as client:
        fut = client.scatter(arr)
        result = da.from_delayed(fut, shape=arr.shape, meta=meta)
        result.compute()
        print("Compute 1, done")

        del fut

        result.compute()
        print("Compute 2, done")


if __name__ == "__main__":
    main()

The first .compute() succeeds. The second .compute(), after the del fut, fails with

❯ python debug.py
Compute 1, done
Traceback (most recent call last):
  File "/home/nfs/toaugspurger/gh/rapidsai/dask-upstream-testing/debug.py", line 44, in <module>
    main()
  File "/home/nfs/toaugspurger/gh/rapidsai/dask-upstream-testing/debug.py", line 21, in main
    result.compute()
  File "/home/nfs/toaugspurger/gh/rapidsai/dask-upstream-testing/.venv/lib/python3.12/site-packages/dask/base.py", line 373, in compute
    (result,) = compute(self, traverse=False, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nfs/toaugspurger/gh/rapidsai/dask-upstream-testing/.venv/lib/python3.12/site-packages/dask/base.py", line 681, in compute
    results = schedule(expr, keys, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nfs/toaugspurger/gh/rapidsai/dask-upstream-testing/.venv/lib/python3.12/site-packages/distributed/client.py", line 2400, in _gather
    raise exception.with_traceback(traceback)
distributed.client.FutureCancelledError: finalize-hlgfinalizecompute-199c06cde2ba4625a856dd08fc888898 cancelled for reason: lost dependencies.

Anything else we need to know?:

I'll look into this tonight or tomorrow.

Environment:

  • Dask version:
In [2]: dask.__version__, distributed.__version__
Out[2]: ('2025.3.0+25.g14f5a90e5', '2025.3.0+14.g3f17ddba')
  • Python version:
  • Operating System:
  • Install method (conda, pip, source):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions