title: How to print out the process name of a process from python's multiprocessing pool
body: <p>I'm trying to figure out what's happening in each process by printing out the process name, identifier, anything.</p>
  
  <p>Below is some test code (code credit to this <a href="https://stackoverflow.com/questions/10190981/get-a-unique-id-for-worker-in-python-multiprocessing-pool">SO question</a>:)</p>
  
  <pre><code>def f(x):
     print multiprocessing.current_process().name
     return x * x
  
  def b():
     p = multiprocessing.Pool()
     print p.map(f, range(6))
  
  def main():
     b()
  </code></pre>
  
  <p>The output it produces is:</p>
  
  <pre><code>PoolWorker-6
  PoolWorker-10
  PoolWorker-10
  PoolWorker-11
  PoolWorker-14
  PoolWorker-15
  [0, 1, 4, 9, 16, 25]
  </code></pre>
  
  <p>Which is what I think I want/need to help me debug what's wrong with my program.  However, my code is slightly different (legacy code I need to fix from someone else).  The code I have below doesn't print the nice PoolWorker ID.</p>
  
  <pre><code>def f(x):
     print multiprocessing.current_process().name
     return x * x
  
  def b():
     p = multiprocessing.Pool()
     for i in range(10):
        p.apply_async(f(i))
  
  def main():
     b()
  </code></pre>
  
  <p>When I run this code, it prints out:</p>
  
  <pre><code>MainProcess
  MainProcess
  MainProcess
  MainProcess
  MainProcess
  MainProcess
  </code></pre>
  
  <p>So my code uses Pool.apply_sync() instead of Pool.map().  How do I print out some unique identifier/name for each process so I have insight into what's happening?  Thanks in advance for your help.</p>