title: python multiprocess update dictionary synchronously
body: <p>I am trying to update one common dictionary through multiple processes. Could you please help me find out what is the problem with this code? I get the following output:</p>
  
  <pre><code>inside function
  {1: 1, 2: -1}
  comes here
  inside function
  {1: 0, 2: 2}
  comes here
  {1: 0, 2: -1}
  </code></pre>
  
  <p>Thanks. </p>
  
  <pre><code>from multiprocessing import Lock, Process, Manager
  
  l= Lock()
  
  
  def computeCopyNum(test,val):
      l.acquire()
      test[val]=val
      print "inside function"
      print test
      l.release()
      return
  
  a=dict({1: 0, 2: -1})
  
  procs=list()
  
  for i in range(1,3):
      p = Process(target=computeCopyNum, args=(a,i))
      procs.append(p)
      p.start()
  
  for p in procs:
  p.join()
      print "comes here"
  
  print a
  </code></pre>