title: Python multiprocessing - tracking the process of pool.map operation
body: <p>I have a function which performs some simulation and
  returns an array in string format.</p>
  
  <p>I want to run the simulation (the function) for
  varying input parameter values, over 10000 possible input values,
  and write the results to a single file.</p>
  
  <p>I am using multiprocessing, specifically, pool.map function
  to run the simulations in parallel.</p>
  
  <p>Since the whole process of running the simulation function over 10000 times
  takes a very long time, I really would like to track the process of the entire operation.</p>
  
  <p>I think the problem in my current code below is that, pool.map runs the function 10000 times, without any process tracking during those operations. Once the parallel processing finishes running 10000 simulations (could be hours to days.), then I keep tracking when 10000 simulation results are being saved to a file..So this is not really tracking the processing of pool.map operation.  </p>
  
  <p>Is there an easy fix to my code that will allow process tracking?</p>
  
  <pre><code>def simFunction(input):
      # Does some simulation and outputs simResult
      return str(simResult)
  
  # Parallel processing
  
  inputs = np.arange(0,10000,1)
  
  if __name__ == "__main__":
      numCores = multiprocessing.cpu_count()
      pool = multiprocessing.Pool(processes = numCores)
      t = pool.map(simFunction, inputs) 
      with open('results.txt','w') as out:
          print("Starting to simulate " + str(len(inputs)) + " input values...")
          counter = 0
          for i in t:
              out.write(i + '\n')
              counter = counter + 1
              if counter%100==0:
                  print(str(counter) + " of " + str(len(inputs)) + " input values simulated")
      print('Finished!!!!')
  </code></pre>