title: Memory issues with python multiprocessing and hundreds of threads active
body: <p>I'm using the package Multiprocessing.dummy, which I read is just the threading package, for reading in some files. I'm also using just Multiprocessing for calculations. I'm running my code in Spyder, and after running it a few times for different files or calculations, I start to get errors with the parallel code. Usually the errors are related to memory, like <code>OS Error: [Errno 12] Cannot allocate memory</code> which occurs in the multiprocessing/threading code.</p>
  
  <p>I noticed that the number of threads keeps increasing, and I'm wondering if this is part of the problem. For example, earlier I saw <code>multiprocessing.threading.active_count() = 277</code>. These are both DummyProcess and Thread threads. Eventually, running the code seems to kill/reset Spyder. My parallel code looks like this:</p>
  
  <pre><code># I/O example
  io_pool = multiprocessing.dummy.Pool()
  io_pool.map(func,files)
  
  # Comp example
  cpu_pool = multiprocessing.Pool()
  cpu_pool.map(func, var)
  </code></pre>
  
  <p>Is there a way to kill the active threads? I can't seem to join or close them, not sure how exactly this works though.</p>