title: The workers in ThreadPoolExecutor is not really daemon
body: <p>The thing I cannot figure out is that although <code>ThreadPoolExecutor</code> uses daemon workers, they will still run even if main thread exit. </p>
  
  <p>I can provide a minimal example in python3.6.4:</p>
  
  <pre><code>import concurrent.futures
  import time
  
  
  def fn():
      while True:
          time.sleep(5)
          print("Hello")
  
  
  thread_pool = concurrent.futures.ThreadPoolExecutor()
  thread_pool.submit(fn)
  while True:
      time.sleep(1)
      print("Wow")
  </code></pre>
  
  <p>Both main thread and the worker thread are infinite loops. So if I use <code>KeyboardInterrupt</code> to terminate main thread, I expect that the whole program will terminate too. But actually the worker thread is still running even though it is a daemon thread.</p>
  
  <p>The source code of <code>ThreadPoolExecutor</code> confirms that worker threads are daemon thread:</p>
  
  <pre><code>t = threading.Thread(target=_worker,
                       args=(weakref.ref(self, weakref_cb),
                             self._work_queue))
  t.daemon = True
  t.start()
  self._threads.add(t)
  </code></pre>
  
  <p>Further, if I manually create a daemon thread, it works like a charm:</p>
  
  <pre><code>from threading import Thread
  import time
  
  
  def fn():
      while True:
          time.sleep(5)
          print("Hello")
  
  
  thread = Thread(target=fn)
  thread.daemon = True
  thread.start()
  while True:
      time.sleep(1)
      print("Wow")
  </code></pre>
  
  <p>So I really cannot figure out this strange behavior.</p>