title: How to determine if running current process is parent?
body: <p>How is it possible to determine from the multiprocessing module in python if the current process is the parent or the child, from within imported modules?</p>
  
  <p>Specifically, I have some lines of code in modules that i am importing, that only want running once - when the code is first run (i.e. not run ever time that a sub-process starts, and imports that module). </p>
  
  <p>In the main module, i was able to achieve this using <code>if __name__ == '__main__':</code> , however this does not work in imported modules. </p>
  
  <p>In case of relevant, current code includes:</p>
  
  <pre><code>import multiprocessing as mp
  
  pool = mp.Pool(processes=7, maxtasksperchild=1) 
  
  all_items = [pool.apply_async(sub_process, args=(value,) for value in all_values]
  for item in all_items:
      item.get()  
  </code></pre>