title: Python stdout during multiprocessing
body: <p>I'm running a scrape on a website and I would like to print out a counter to show progress. I had this working during serial processing. (It's a two step scrape)</p>
  
  <pre><code>from multiprocessing import Pool
  from sys import stdout
  from bs4 import BeautifulSoup
  
  global searched_counter,processed_counter
  searched_counter = 0
  processed_counter = 0
  
  def run_scrape(var_input):
      global searched_counter,processed_counter
      #get search results
      parsed = #parse using bs4
  
      searched_counter += 1
      stdout.write("\rTotal Searched/Processed: %d/%d" % (searched_counter,processed_counter))
      stdout.flush()
  
      if parsed:       #only go to next page if result is what I want
          #get the page I want using parsed data
          #parse some more and write out to file
  
          processed_counter += 1
          stdout.write("\rTotal Searched/Processed: %d/%d" % (searched_counter,processed_counter))
          stdout.flush()    
  
  
  list_to_scrape = ["data%05d" % (x,) for x in range(1,10000)]
  pool = Pool(8)
  pool.map(run_scrape,list_to_scrape)
  
  stdout.write('\n')
  </code></pre>
  
  <p>When I run it with multiprocessing, it goes haywire and prints a lot of random numbers that don't add up to what it's actually writing to the file...</p>