title: Do threads in python need to be joined to avoid leakage?
body: <p>I understand the purpose of joining a thread, I'm asking about resource use.  My specific use-case here is that I have a long-running process that needs to spawn many threads, and during operation, checks if they have terminated and then cleans them up.  The main thread waits on inotify events and spawns threads based on those, so it can't block on <code>join()</code> calls, because it needs to block on inotify calls.</p>
  
  <p>I know that with pthreads, for instance, not joining a terminated thread will cause a resource leak:</p>
  
  <blockquote>
    <p>PTHREAD_JOIN(3): Failure to join with a thread that is joinable (i.e., one that is not detached), produces a "zombie thread".  Avoid doing this,  since  each  zombie thread consumes some system resources, and when enough zombie threads have accumulated, it will no longer be possible to create new threads (or processes).</p>
  </blockquote>
  
  <p>Python's documentation says no such thing, though, but it also doesn't specify that the join() can be disregarded without issue if many threads are expected to end on their own without being joined during normal operation.</p>
  
  <p>I'm wondering, can I simply take my thread list and do the following:</p>
  
  <pre><code>threads = [thread for thread in threads if thread.is_alive()]
  </code></pre>
  
  <p>For each check, or will this leak?  Or must I do the following?</p>
  
  <pre><code>alive_threads = list()
  for thread in threads:
      if thread.is_alive():
          alive_threads.append(thread)
      else:
          thread.join()
  threads = alive_threads
  </code></pre>