
I'm trying to get a simple webserver working using twisted. It works, to some extent, serves pages and all, but it blocks until the reactor.callLater(...) is done... what am I doing wrong? Dave # CODE from twisted.web import server from twisted.web.resource import Resource from twisted.internet import reactor, defer import pprint dump = pprint.PrettyPrinter(indent=4).pformat def requestDebug(r): r.write('<pre>'+ dump(r.headers) +'</pre>') reactor.callLater(5, r.finish) class NonBlock(Resource): """ I should be a non-blocking resource that takes 5s to load. Instead, each request waits for any others to finish. """ def getChild(self, path, request): return self isLeaf=False def render_GET(self, request): d = defer.Deferred() d.addCallback(requestDebug) d.callback(request) return server.NOT_DONE_YET from twisted.application import service, internet application = service.Application("nonblock") internet.TCPServer(8080, server.Site(NonBlock()) ).setServiceParent(application)