title: changing global variable when multiprocessing in python
body: <p>So what I am trying to do ultimately is read a line, do some calculations with the info in that line, then add the result to some global object, but I can never seem to get it to work. For instance, test is always 0 in the code below. I know this is wrong, and I have tried doing it other ways, but it still isn't working. </p>
  
  <pre><code>import multiprocessing as mp
  
  File = 'HGDP_FinalReport_Forward.txt'
  #short_file = open(File)
  test = 0
  
  def pro(temp_line):
      global test
      temp_line = temp_line.strip().split()
      test = test + 1
      return len(temp_line)
  
  if __name__ == "__main__":
      with open("HGDP_FinalReport_Forward.txt") as lines:
          pool = mp.Pool(processes = 10)
          t = pool.map(pro,lines.readlines())
  </code></pre>