如何从购物袋中获取未来的物品?

时间:2018-09-02 08:18:18

标签: dask

我需要从将来调用回调函数以对任务执行重试逻辑。但是我不知道如何从轻装上阵。

例如,这是使用快装袋的方式

b = db.from_sequence(['1.dat', '2.dat', ...]).map(process_filename)
b.compute()
# I need a callback function when a task is finish with a single file to have complex retry logic
# I can get a future object from client.submit(my_args).add_done_callback(my_call_back) but I don't want to use client.submit because of large data set

1 个答案:

答案 0 :(得分:0)

您可以通过以下方式从袋子分区中获取期货:

from dask.distributed import futures_of

b = b.persist()
futures = futures_of(b)