title: Joblib doesn't call a custom function when n_jobs > 1
body: <p>I have an example with data. </p>
  
  <p>As you can see from the code, every call of a function <code>fit_by_idx()</code> has to print <code>'here'</code>, but it doesn't. All is ok when <code>n_jobs=1</code>, but if <code>n_jobs</code> is more, than <code>joblib</code> does not call the function.</p>
  
  <p>Code:</p>
  
  <pre><code>import statsmodels.tsa.holtwinters as holtwinters
  import pandas as pd
  import numpy as np
  from joblib import Parallel, delayed
  
  train = pd.read_csv('train.csv').drop(columns=['id'])
  
  
  def iter_predict(data, model, steps, fit_args=[],  fit_kwargs={}): # steps - кол. предсказываемых точек
      def fit_by_idx(idx):
          print('here')
          endog = data.iloc[idx]
          fitted = model(endog).fit(*fit_args, optimized=False, **fit_kwargs)\
          res[idx, :] = fitted.forecast(steps)
  
      res = np.zeros((data.shape[0], steps))
      Parallel(n_jobs=2)(delayed(fit_by_idx)(idx) for idx in range(data.shape[0]))
      return res
  
  iter_predict(train, holtwinters.SimpleExpSmoothing, 2, fit_kwargs={'smoothing_level': 0.5})
  </code></pre>
  
  <p>And here's the link to the <a href="https://drive.google.com/open?id=1TcoyHYjKPuwFW4PNBUB0TT6RqtdpzvSv" rel="nofollow noreferrer">dataset</a>.</p>