首页 > 解决方案 > Dask Future 的状态为“已取消”,但未被取消

问题描述

我正在构建一个 dask 应用程序并将 Dask SSH-Cluster 用作集群。当我在 Dask 中运行任务并尝试等待它时,它会导致concurrent.futures._base.CancelledError错误。

我的代码如下:

def run_custom_task():
    return "aa"


def main():
    cluster = SSHCluster(hosts=['localhost', 'pi01.local'],
                         connect_options=[{'username': 'abc'}, {'username': 'pi'}],
                         worker_options={
                             "nprocs": 1,
                             "nthreads": 1
                         }, 
                         remote_python="/usr/bin/python3")
    client = Client(cluster)

    res = client.submit(run_custom_task)
    print(res.result())

我收到的确切错误是:

Traceback (most recent call last):
  File "test.py", line 65, in <module>
    main()
  File "test.py", line 59, in main
    x = res.result()
  File "/home/rohan/.local/lib/python3.8/site-packages/distributed/client.py", line 222, in result
    raise result
concurrent.futures._base.CancelledError: run_custom_task-966de894af6e709f1e8067f6e9ffe68

所以似乎这项任务的未来正在以某种方式被取消。

提前致谢!

标签: pythondaskdask-distributedconcurrent.futuresdask-ssh

解决方案


我实际上已经设法解决了这个问题:问题是安装相同版本后 dask.distributed 和 dask 版本不同(2021.04.0 和 2021.05.0),此错误已解决。


推荐阅读