使用一个简单的dask方法执行一个简单的dask方法失败。在
有人能给我指出正确的方向吗。在
下面是我正在运行的代码:
from dask.distributed import Client, as_completed
import time
class DaskConnect:
def __init__(self):
print("Initialized:",self.__class__.__name__)
self.scheduler_host="192.168.0.4"
self.scheduler_port="8786"
def connect(self):
self.client = Client(self.scheduler_host+":"+self.scheduler_port)
# self.client = Client()
return self.client
def disconnect(self):
self.client.close()
class TestDask:
def __init__(self):
print("Initialized:",self.__class__.__name__)
self.dask_client=DaskConnect().connect()
def do_task(self,msg):
time.sleep(30)
return msg
def run(self):
tasks=[1]
# tasks = [1, 2, 3, 4, 5]
futures=[]
for task in tasks:
print("Submitting:",task)
future = self.dask_client.submit(self.do_task, "Task:"+str(task))
futures.append(future)
for future in as_completed(futures):
result = future.result()
print("Result",result)
TestDask().run()
错误:
distributed.protocol.pickle - INFO - Failed to serialize main.TestDask object at 0x101c408d0>>. Exception: can't pickle select.kqueue objects Traceback (most recent call last):
Dask客户端当前不可序列化。任何包含Dask客户机的对象也不能序列化。通常,序列化包含活动网络连接、锁等的任何内容都是一个挑战。。在
也许你的问题还有别的办法?在
相关问题 更多 >
编程相关推荐