Scenario: User A connects to dask scheduler, sends a long job using client.map(func, list)
and logs off for the weekend. User B wants to view the results of the finished Futures created by User A and possibly cancel the pending futures.
We managed to get the results of futures present in the workers as follows:
from dask.distributed import Client
from distributed.client import Future
client = Client("tcp://scheduler_ip:8786")
for worker, futures in client.has_what().items():
for future_id in futures:
f = Future(future_id, client)
f._state.status = "finished"
print(f.result())
Doing an f.cancel()
does nothing. Is there a way to achieve this?
Share futures
You might consider sharing futures using constructs like Variables and Queues. See these docs for more information.
Cancel futures
Cancel will stop a task if it hasn't yet started. Unfortunately, once a function has started running there is no way to stop it short of killing that worker.