I am trying to do something like
resource = MyResource()
def fn(x):
something = dosemthing(x, resource)
return something
client = Client()
results = client.map(fn, data)
The issue is that resource
is not serializable and is expensive to construct.
Therefore I would like to construct it once on each worker and be available to be used by fn
.
How do I do this?
Or is there some other way to make resource
available on all workers?