title: python and ipython threading.activeCount()
body: <p>I have a module that imports threading and uses <a href="http://docs.python.org/2/library/threading.html#threading.activeCount" rel="nofollow">threading.activeCount()</a> to determine when all threads are done. I initially wrote my module using the standard python interpreter. Using my module in a script is fine, however when importing my module in ipython and calling a function that depends on threading.activeCount(). My function never returns.</p>
  
  <p>Code:</p>
  
  <pre><code>for dev in run_list:
     proc = threading.Thread(target=go, args=[dev])
     proc.start()
  
  while threading.activeCount() &gt; 1:
     time.sleep(1)
  </code></pre>
  
  <p>I noted that when first importing threading with the standard interpreter and calling threading.activeCount(), only 1 thread is counted: </p>
  
  <pre><code>&gt;&gt;&gt; import threading
  &gt;&gt;&gt; threading.activeCount()
  1
  &gt;&gt;&gt; threading.enumerate()
  [&lt;_MainThread(MainThread, started 140344324941568)&gt;]
  </code></pre>
  
  <p>However when using the ipython, the initial count is 2:</p>
  
  <pre><code>In [1]: import threading
  
  In [2]: threading.activeCount()
  Out[2]: 2
  
  In [3]: threading.enumerate()
  Out[3]: 
  [&lt;_MainThread(MainThread, started 140674997614336)&gt;,
   &lt;HistorySavingThread(Thread-1, started 140674935068416)&gt;]
  </code></pre>
  
  <p>This module is used by various people using various interpreters to work, so I'm wondering if there is a better way to handle this (preferably still using threading)?</p>