In this post is discussed that already started tasks can not be canceled in Dask (language limitation).
But what if I just want to omit those tasks?
start_computing_time = time.time()
for future in task_pool:
if condition:
do_something_long(future.result())
else:
future.cancel()
total_computing_time = time.time() - start_computing_time
In my application, execution time is critical. Once the stopping condition is met, I just want to omit running tasks, as I am no longer interested on those results. As to my knowledge, future.cancel()
will just cancel not yet running futures.
But for those tasks in execution, is there any way to ignore them?
Thank you in advance!