class BaseTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): allow_reuse_address = 1 # Seems to make sense in testing environment def __init__(self, gc, name, server_address, RequestHandlerClass): self.gc = gc self.name = name SocketServer.TCPServer.__init__(self, server_address, RequestHandlerClass) def server_activate(self): SocketServer.TCPServer.server_activate(self) self._pool = Pool(self.gc, self.name+'_pool', factory = self.RequestHandlerClass, factory_param = [self, self.gc]) self.gc.registerProvider(self._pool) def finish_request(self, request, client_address): """Finish one request by instantiating RequestHandlerClass.""" # self.RequestHandlerClass(request, client_address, self, self.gc) handler = self._pool.get() handler.awake(request, client_address) handler.setup() handler.handle() handler.finish() self._pool.finish(handler)
def server_activate(self): SocketServer.TCPServer.server_activate(self) self._pool = Pool(self.name+'_pool', factory = self.RequestHandlerClass, factory_param = [self], pool = 40) self.GC.registerProvider(self._pool)