title: python parallel map (multiprocessing.Pool.map) with global data
body: <p>I'm trying to call a function on multiple processes.  The obvious solution is python's <code>multiprocessing</code> module.  The problem is that the function has side effects.  It creates a temporary file and registers that file to be deleted on exit using the <code>atexit.register</code> and a global list.  The following should demonstrate the problem (in a different context).</p>
  
  <pre><code>import multiprocessing as multi
  
  glob_data=[]
  def func(a):
      glob_data.append(a)
  
  map(func,range(10))
  print glob_data  #[0,1,2,3,4 ... , 9]  Good.
  
  p=multi.Pool(processes=8)
  p.map(func,range(80))
  
  print glob_data  #[0,1,2,3,4, ... , 9] Bad, glob_data wasn't updated.
  </code></pre>
  
  <p>Is there any way to have the global data updated?</p>
  
  <p>Note that if you try out the above script, you probably shouldn't try it from the interactive interpreter since <code>multiprocessing</code> requires the module <code>__main__</code> to be importable by child processes.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Added the <code>global</code> keyword in func doesn't help -- e.g.:</p>
  
  <pre><code>def func(a):  #Still doesn't work.
      global glob_data
      glob_data.append(a)
  </code></pre>