title: python multiprocessing on windows, if __name__ == "__main__"
body: <p>Running python 2.7 on windows 7 (64bit).</p>
  
  <p>When reading the docs for library module <code>multiprocessing</code>, it states several times the importance of the <code>__main__</code> module, including the conditional (especially in Windows):</p>
  
  <pre><code>if __name__ == "__main__":
      # create Process() here
  </code></pre>
  
  <p>My understanding, is that you don't want to create Process() instances in the global namespace of the module (because when the child process imports the module, he will spawn yet another inadvertently).</p>
  
  <p>I do not have to place Process managers at the very top level of my package execution hierarchy though (execution in the PARENT). As long as my Process()'s are created, managed, and terminated in a class method, or even in a function closure. Just not in the toplevel module namespace.</p>
  
  <p>Am I understanding this warning/requirement correctly?</p>
  
  <hr>
  
  <h1>EDIT</h1>
  
  <p>After the first two responses, I add this quotation. This is in the introduction for <strong>Section 16.6 multiprocessing</strong> from the 2.7 docs.</p>
  
  <blockquote>
    <p><em>Note</em>: Functionality within this package requires that the <code>__main__</code> module be importable by the children. This is covered in Programming
    guidelines however it is worth pointing out here.This means that some
    examples, such as the <code>multiprocessing.Pool</code> examples will not work in
    the interactive interpreter...</p>
  </blockquote>