title: Python's multiprocessing. The program does not finish join()
body: <p>I have a program which a use a lot. Therefore I wish to make it faster and trying to do multiprocessing. It kind of worked fine when I made the program use a low resolution (I am doing a power spectrum; low resolution means it will be done fast but it will not be very accurate). I got a ~2x speed up, but when doing a high resolution I terminated it before it was finish, after it had runned for a longer time than with the single processor.</p>
  
  <p>My main file is something like this (I have defined <code>f_min,f_max,df,t,f</code>)</p>
  
  <pre><code>import multiprocessing as mp
  from ast_power import power_spectrum
  
  tasks = mp.cpu_count()
  bound = mp.Queue()
  res   = mp.Queue()
  mint  = [mp.Process(target=power_spectrum,args=(t,f,bound,res)) for i in range(tasks)]
  
  
  DF = (f_max-f_min)/tasks
  for i in mint:
      i.start()
  for i in range(1,tasks+1):
      a = i*f_min
      b = a+DF
      c = df
      d = 1
      bound.put([a,b,c,d])
  for i in mint:
      i.join()
  fr,p = [],[]
  while tasks:
      frp,pp = res.get()
      frp,pp = list(frp),list(pp)
      fr += frp
      p  += pp
      tasks -= 1
  </code></pre>
  
  <p>And my <code>ast_power</code> look like this</p>
  
  <pre><code>import numpy as np
  def power_spectrum(time, data, param, R='None' ):
  
  
      if R == 'None': #Normal
          f_min = param[0]
          f_max = param[1]
          df    = param[2]
          w     = param[3]
      else: # Multiprocessing
          f_min,f_max,df,w = param.get()
      freq = np.arange(f_min,f_max,df)    
  
      for i in xrange( len(freq) ):
          # Do the power spectrum...
          # will produce; power, alfa, beta
  
      if R == 'None': #Normal
          return freq,power,alfa,beta
      else: #Multiprocessing
          R.put([freq,power,alfa,beta])
  </code></pre>
  
  <p>Is I doing it right? I think it is very strange that it works for high <code>df</code> (low res.) and not for low <code>df</code> (high res.)</p>
  
  <p>Any help is very preciated.</p>