title: Why is CTRL-C not captured and signal_handler called?
body: <p>I have the following standard implementation of capturing <kbd>Ctrl+C</kbd>:</p>
  
  <pre><code>def signal_handler(signal, frame):
      status = server.stop()
      print("[{source}] Server Status: {status}".format(source=__name__.upper(),
                                                        status=status))
      print("Exiting ...")
  
      sys.exit(0)
  
  
  signal.signal(signal.SIGINT, signal_handler)
  </code></pre>
  
  <p>On <code>server.start()</code> I am starting a threaded instance of CherryPy. I created the thread thinking that <em>maybe since CherryPy is running, the main thread is not seeing the <kbd>Ctrl+C</kbd>.</em> This did not seem to have any affect but posting the code as I have it now:</p>
  
  <p><strong>__main__</strong>:  </p>
  
  <pre><code>   server.start()  
  </code></pre>
  
  <p><strong>server</strong>:</p>
  
  <pre><code>def start(self):
      # self.engine references cherrypy.engine
      self.__cherry_thread = threading.Thread(target=self.engine.start)
  
      self.status['running'] = True
      self.status['start_time'] = get_timestamp()
  
      self.__cherry_thread.start()  
  
  def stop(self):
      self.status['running'] = False
      self.status['stop_time'] = get_timestamp()
  
      self.engine.exit()
      self.__thread_event.set()
  
      return self.status
  </code></pre>
  
  <p>When I press <kbd>Ctrl+C</kbd> the application does not stop. I have placed a breakpoint in the <code>signal_handler</code> above and it is never hit.</p>