title: PicklingError from Dask when calling Client.Submit
body: <p>I have a backtesting engine which I have tried to parallelise using dask. I can treat each week of data independently, so I thought I could easily parallelise by firing off a worker that would create a complete instance of the backtest engine and run it on one week of data. </p>
  
  <p>Here is the outline code I tried based on the <a href="http://dask.pydata.org/en/latest/futures.html" rel="nofollow noreferrer">Dask Futures docs</a>.</p>
  
  <pre><code>from dask.distributed import Client
  from backtest_engine import *
  
  def run_backtest(start_date, end_date):
      engine = backtest_engine()
      engine.price_spread = 2
      engine.emulate_ticks = True
      engine.run_walk_forward(start_date, end_date, 'my_market', my_strategy_class)
      return True
  
  if __name__ == "__main__":
      client = Client()
      a = client.submit(run_backtest, datetime(2017,9,3), datetime(2017,9,9))
      b = client.submit(run_backtest, datetime(2017,9,10), datetime(2017,9,17))
  </code></pre>
  
  <p>The code fails on the call to <code>client.submit()</code> with:</p>
  
  <p><code>_pickle.PicklingError: Could not pickle object as excessively deep recursion required.</code></p>
  
  <p>Is there something wrong with the code, or is my approach fundamentally flawed in some way, or are there restrictions in what calls I can make within a worker?</p>
  
  <p>Ian </p>
  
  <p>For background: <code>run_walk_forward()</code> loads an HD5 file into a Pandas dataframe, iterates over the dataframe to produce results, then writes the results to disk.</p>