title: Python twisted not catching exception
body: <p>My main class is something like</p>
  
  <pre><code># file bmdaemon.py
  from txjsonrpc.web import jsonrpc
  from twisted.web import server, xmlrpc
  from twisted.internet import reactor, defer, threads, task
  import xmlrpclib
  from txjsonrpc.web.jsonrpc import Proxy
  
  
  class BMDaemon(jsonrpc.JSONRPC):
      # class definition
  
  
  class XmlRpcInterface(xmlrpc.XMLRPC):
       # class definition
  
  
  if __name__ == "__main__":
      try:
          bm_daemon = BMDaemon()
          xml_interface = XmlRpcInterface()
          portJSONRPC = bm_daemon.get_listeningJSON_port()
          portXMLRPC = bm_daemon.get_listeningXML_port()
          reactor.listenTCP(portJSONRPC, server.Site(bm_daemon))
          reactor.listenTCP(portXMLRPC, server.Site(xml_interface))
          reactor.run()
      except KeyboardInterrupt:
          print "MAIN: ^C received, exiting."
  </code></pre>
  
  <p>And I'm just trying catching <code>CTRL+C</code> at the outer level, <em>i.e.</em> the "main" execution.</p>
  
  <p>However, sending the mentioned keyboard interrupt just prints</p>
  
  <pre><code>&lt;&lt; prints from BMDaemon &gt;&gt;
  ^CUnhandled error in Deferred:
  Unhandled Error
  Traceback (most recent call last):
    File "bmdaemon.py", line 562, in &lt;module&gt;
      bm_daemon = BMDaemon()
    File "bmdaemon.py", line 114, in __init__
      &lt;&lt; some line &gt;&gt;
    File "/usr/lib/python2.7/dist-packages/twisted/internet/task.py", line 170, in start
      self()
    File "/usr/lib/python2.7/dist-packages/twisted/internet/task.py", line 215, in __call__
      d = defer.maybeDeferred(self.f, *self.a, **self.kw)
  --- &lt;exception caught here&gt; ---
    File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 134, in maybeDeferred
      result = f(*args, **kw)
    File "bmdaemon.py", line 519, in __registration
      &lt;&lt; some line &gt;&gt;
    File "/usr/lib/python2.7/commands.py", line 60, in getstatusoutput
      text = pipe.read()
  exceptions.KeyboardInterrupt: 
  &lt;&lt; prints from XmlRpcInterface &gt;&gt;
  </code></pre>
  
  <p>In other words, I'm not catching the requested error !
  Please be patient since I come from a Java environment where a situation like that would be much cleaner to understand.</p>