title: Parallel code hangs if run first, but works if run after running non-parallel code
body: <p>So this sounds a bit convoluted, but I've had a problem with joblib lately where it will create a bunch of processes and then just hang there (aka, each process takes up memory, but uses no CPU time).</p>
  
  <p>Here is the simplest code I've got that will reproduce the problem:</p>
  
  <pre><code>from sklearn import linear_model
  import numpy as np
  from sklearn import cross_validation as cval
  from joblib import Parallel, delayed
  
  def fit_hanging_model(n=10000, nx=10, ny=32, ndelay=10,
                         n_cvs=5, n_jobs=None):
      # Create data
      X = np.random.randn(n, ny*ndelay)
      y = np.random.randn(n, nx)
  
      # Create model + CV
      model = linear_model.Ridge(alpha=1000.)
      cvest = cval.KFold(n, n_folds=n_cvs, shuffle=True)
  
      # Fit model
      par = Parallel(n_jobs=n_jobs, verbose=10)
      parfunc = delayed(_fit_model_cvs)
      par(parfunc(X, y, train, test, model)
                        for i, (train, test) in enumerate(cvest))
  
  def _fit_model_cvs(X, Y, train, test, model):
      model.fit(X, Y)  
  
  n = 10
  a = np.random.randn(n, 32) 
  b = np.random.randn(32, 10)
  
  ##########
  c = np.dot(a, b)
  ##########
  
  fit_hanging_model(n_jobs=3)
  </code></pre>
  
  <p>Here is what happens:</p>
  
  <ul>
  <li>If I run all of the code above, then it spawns off three processes and hangs</li>
  <li>If I run all of the code above, but use n_jobs=1, then it works fine</li>
  <li>If I run all of the code above a second time, after running it once with n_jobs=1, then it works fine no matter how many jobs I use.</li>
  <li>If I run all of the code above EXCEPT for the code between the ######, then it runs fine.</li>
  <li>However, if I then run the code between the ######, and try to run fit_hanging_model with n_jobs > 1, then it hangs</li>
  </ul>
  
  <p>This is with joblib = 0.8.0, and sklearn 0.15-git.</p>
  
  <p>Note, this bug is on CentOS on linux. I have not been able to reproduce this bug on another machine, so it may be hard to reproduce. </p>
  
  <p>Does anyone have any idea why this might be going on? It seems like that dot product is doing something strange, but I have no idea what it could be...I'm at the end of my rope...</p>