title: Losing the local client when calling dark inside of a distributed-spawned function
body: <p>I am trying to perform some task operations inside of a function which is sent to a worker through distributed. A simplified version of the code is</p>
  
  <pre><code>client = Client(...)
  X_ = dask.array.from_array(...)
  X = dask.persist(X_)
  def func(X, b):
       with distributed.local_client() as c:
             with dask.set_options(get=c.get):
                   return dask.lu_solve(X, b)
  
  client.persist(dask.do(func)(X, b))
  </code></pre>
  
  <p>The problem is that in doing for several <code>X</code>, <code>b</code> instances, sometimes it works and sometimes I get the Exception <code>Exception: Client not running.  Status: closed</code></p>
  
  <p>any idea on how to address this?</p>