title: How to prevent Exception ignored in: <module 'threading' from ... > while setting signal handler?
body: <p>Having this code: </p>
  
  <pre><code>def signal_handler(signal, frame):
      print("exiting")
      sys.exit(0)
  
  if __name__ == "__main__":
      signal.signal(signal.SIGINT, signal_handler)
  
      threads_arr = []
      for i in list:
          t = threading.Thread(target=myFunc, args=(i))
          threads_arr.append(t)
          t.start()
  </code></pre>
  
  <p>How can I prevent this on pressing <kbd>Ctrl</kbd>+<kbd>C</kbd></p>
  
  <pre><code>Exception ignored in: &lt;module 'threading' from '/usr/lib/python3.4/threading.py'&gt;
  Traceback (most recent call last):
    File "/usr/lib/python3.4/threading.py", line 1294, in _shutdown
      t.join()
    File "/usr/lib/python3.4/threading.py", line 1060, in join
      self._wait_for_tstate_lock()
    File "/usr/lib/python3.4/threading.py", line 1076, in _wait_for_tstate_lock
      elif lock.acquire(block, timeout):
    File "./script.py", line 28, in signal_handler
      sys.exit(0)
  SystemExit: 0
  </code></pre>
  
  <p>where line 28 is pointing at <code>sys.exit(0)</code>?</p>
  
  <p><strong>EDIT</strong> 
  After trying to add <code>t.join()</code> (or <code>t.join(1)</code>) in the last <code>for</code> loop in <code>main</code> I get the same although I have to press <kbd>Ctrl</kbd>+<kbd>C</kbd> to get this error and exit the program.</p>