title: KeyError: 0 using multiprocessing in python
body: <p>I have the following code inwhich I try to call a function compute_cluster which do some computations and write the results in a txt file (each process write its results in different txt files independently), however, when I run the following code: </p>
  
  <pre><code>def main():
    p = Pool(19)
    p.map(compute_cluster, [(l, r) for l in range(6, 25) for r in range(1, 4)]) 
    p.close()
  if __name__ == "__main__":
     main()                
  </code></pre>
  
  <p>it crashes with the following errors:</p>
  
  <pre><code>File "RMSD_calc.py", line 124, in &lt;module&gt;
    main()                
  File "RMSD_calc.py", line 120, in main
    p.map(compute_cluster, [(l, r) for l in range(6, 25) for r in range(1, 4)]) 
  File "/usr/local/lib/python2.7/multiprocessing/pool.py", line 225, in map
    return self.map_async(func, iterable, chunksize).get()
  File "/usr/local/lib/python2.7/multiprocessing/pool.py", line 522, in get
    raise self._value
    KeyError: 0
  </code></pre>
  
  <p>and when I searched online for the meaning of "KeyError: 0" i didn't find anything helpful so any suggestions why this error happens is highly appreciated </p>