title: multiprocessing.Pool example
body: <p>I'm trying to learn how to use <a href="http://docs.python.org/2/library/multiprocessing.html">multiprocessing</a>, and found <a href="http://forum.openopt.org/viewtopic.php?id=51">the following example</a>.</p>
  
  <p>I want to sum values as follows:</p>
  
  <pre><code>from multiprocessing import Pool
  from time import time
  
  N = 10
  K = 50
  w = 0
  
  def CostlyFunction(z):
      r = 0
      for k in xrange(1, K+2):
          r += z ** (1 / k**1.5)
      print r
      w += r
      return r
  
  currtime = time()
  
  po = Pool()
  
  for i in xrange(N):
      po.apply_async(CostlyFunction,(i,))
  po.close()
  po.join()
  
  print w
  print '2: parallel: time elapsed:', time() - currtime
  </code></pre>
  
  <p>I can't get the sum of all r values.</p>