title: How to update global variable in python multiprocessing
body: <pre><code>#!/usr/bin/env python
  import signal
  import time
  import sys
  import multiprocessing
  
  idx = 0
  
  def worker_function():
      global idx
      idx = idx + 1
      print("idx = {0}\n".format(idx))
      time.sleep(1)
  
  
  def main():
      for i in range(3):
          worker = multiprocessing.Process(target=worker_function, args=())
          worker.start()
          worker.join()
  
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>output is as follows:</p>
  
  <pre><code>idx = 1
  
  idx = 1
  
  idx = 1
  </code></pre>
  
  <p><strong>Question</strong>> Why the python global variable cannot be updated by each individual process?</p>