I am using dask
library trying to create multi threaded programs. But I am facing a problem here.
Example:
from dask import compute, delayed
import dask.multiprocessing
arr = []
def add():
arr.append("a")
tasks = [delayed(add)(),delayed(add)()]
compute(*tasks, get = dask.multiprocessing.get)
print(arr)
This code's output is simply [ ]
.. because I am using multiprocessing. If I am using get = dask.threaded.get
The code's output will be = ['a', 'a']
I also need to use multiprocessing to achieve actual parallelism on multiple cores.
So my question is.. is there a way to use dask.multiprocessing and still have the ability to access a shared object?