title: Twisted: Creating a ThreadPool and then daemonizing leads to uninformative hangs
body: <p>I am developing a networked application in Twisted, part of which consists of a web interface written in Django.</p>
  
  <p>I wish to use Twisted's WSGI server to host the web interface, and I've written a working "tap" plugin to allow me to use <code>twistd</code>.</p>
  
  <p>When running the server with the <code>-n</code> flag (don't daemonize) everything works fine, but when this flag is removed the server doesn't respond to requests at all, and there are no messages logged (though the server is still running).</p>
  
  <p>There is a <a href="http://twistedmatrix.com/trac/ticket/4347" rel="noreferrer">bug on Twisted's Trac</a> which seems to describe the problem exactly, and my plugin happens to be based on the <a href="http://paste.pocoo.org/show/185480/" rel="noreferrer">code referenced in the ticket</a>.</p>
  
  <p>Unfortunately, the issue hasn't been fixed - and it was raised almost a year ago.</p>
  
  <p>I have attempted to create a <code>ThreadPoolService</code> class, which extends <code>Service</code> and starts a given <code>ThreadPool</code> when <code>startService</code> is called:</p>
  
  <pre><code>class ThreadPoolService(service.Service):
      def __init__(self, pool):
          self.pool = pool
  
      def startService(self):
          super(ThreadPoolService, self).startService()
          self.pool.start()
  
      def stopService(self):
          super(ThreadPoolService, self).stopService()
          self.pool.stop()
  </code></pre>
  
  <p>However, Twisted doesn't seem to be calling the <code>startService</code> method at all. I think the problem is that with a "tap" plugin, the <code>ServiceMaker</code> can only return <em>one</em> service to be started - and any others belonging to the same application aren't started. Obviously, I am returning a <code>TCPServer</code> service which contains the WSGI root.</p>
  
  <p>At this point, I've hit somewhat of a bit of a brick wall. Does anyone have any ideas as to how I can work round this issue?</p>